23 lines
546 B
Mojo
23 lines
546 B
Mojo
# probe: declared inside a loop body: does each pass destroy its own value at its last use?
|
|
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():
|
|
for i in range(2):
|
|
var a = L(String(i))
|
|
print("pass uses", a.n)
|
|
print("pass after use")
|
|
print("after loop")
|