23 lines
547 B
Mojo
23 lines
547 B
Mojo
# probe: declared before a loop, read in every pass: does it die after the loop, or in the last pass?
|
|
struct L(Copyable, Movable):
|
|
var n: String
|
|
|
|
def __init__(out self, n: String):
|
|
self.n = n
|
|
print("init", n)
|
|
|
|
def __init__(out self, *, deinit move: Self):
|
|
self.n = move.n^
|
|
print("move", self.n)
|
|
|
|
def __deinit__(deinit self):
|
|
print("bye", self.n)
|
|
|
|
|
|
def main():
|
|
var a = L("a")
|
|
for i in range(2):
|
|
print("pass", i, a.n)
|
|
print("pass after use", i)
|
|
print("after loop")
|