This commit is contained in:
commit
568474d52f
1591 files changed
+528213
No files matched your search
@@ -0,0 +1,29 @@
|
||||
# probe: an early return: is the value destroyed before the return on that path?
|
||||
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) -> Int:
|
||||
var a = L("a")
|
||||
if flag:
|
||||
print("returning early")
|
||||
return 1
|
||||
print("late uses", a.n)
|
||||
return 2
|
||||
|
||||
|
||||
def main():
|
||||
print(run(True))
|
||||
print("---")
|
||||
print(run(False))
|
||||
Reference in new issue
Block a user