Baseline: tree as shared

This commit is contained in:
alexm committed 2026-10-05 03:03:38 +00:00
commit 31f2fb8a5a
1679 files changed
+1024562

No files matched your search

+38
View File
@@ -0,0 +1,38 @@
# probe: copy and move constructors through var arguments and transfers
# status: the expected output is Programming+'s interpreter's prediction; corpus.py verify confirms or refutes it on godbolt
# expect-stdout: new a
# expect-stdout: copy a
# expect-stdout: consumed a+
# expect-stdout: free a+
# expect-stdout: move a
# expect-stdout: holding a
# expect-stdout: free a
struct Box(Copyable, Movable):
var label: String
def __init__(out self, label: String):
self.label = label
print("new", label)
def __init__(out self, *, copy: Self):
self.label = copy.label + "+"
print("copy", copy.label)
def __init__(out self, *, deinit move: Self):
self.label = move.label^
print("move", self.label)
def __deinit__(deinit self):
print("free", self.label)
def consume(var b: Box):
print("consumed", b.label)
def main():
var a = Box("a")
var b = a.copy()
consume(b^)
var c = a^
print("holding", c.label)