This commit is contained in:
commit
568474d52f
1591 files changed
+528213
No files matched your search
@@ -0,0 +1,31 @@
|
||||
# probe: Stage 4 prediction: an unread value dies after its declaration; a value borrowed by print lives until print returns
|
||||
# expect-stdout: init a
|
||||
# expect-stdout: init b
|
||||
# expect-stdout: bye b
|
||||
# expect-stdout: using a
|
||||
# expect-stdout: bye a
|
||||
# expect-stdout: end
|
||||
struct L(Copyable, Movable):
|
||||
var n: String
|
||||
|
||||
def __init__(out self, n: String):
|
||||
self.n = n
|
||||
print("init", n)
|
||||
|
||||
def __init__(out self, *, copy: Self):
|
||||
self.n = copy.n + "2"
|
||||
print("copy", copy.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")
|
||||
var b = L("b")
|
||||
print("using", a.n)
|
||||
print("end")
|
||||
Reference in new issue
Block a user