32 lines
689 B
Mojo
32 lines
689 B
Mojo
# probe: used in the then branch only: in the else branch, where does it die (before the else body, after it, or after the if)?
|
|
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):
|
|
var a = L("a")
|
|
print("before if")
|
|
if flag:
|
|
print("then uses", a.n)
|
|
print("then after use")
|
|
else:
|
|
print("else body")
|
|
print("after if")
|
|
|
|
|
|
def main():
|
|
run(True)
|
|
print("---")
|
|
run(False)
|