27 lines
554 B
Mojo
27 lines
554 B
Mojo
# probe: declared inside a branch and used there: does it die within the branch?
|
|
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 run(flag: Bool):
|
|
if flag:
|
|
var a = L("a")
|
|
print("then uses", a.n)
|
|
print("then after use")
|
|
print("after if")
|
|
|
|
|
|
def main():
|
|
run(True)
|