Files
pplus-library/mojo/probes/struct-field-loop-copy.mojo
alexm 568474d52f
Test (in pplus-core) / in-core (push) Failing after 28m44s
Initial commit
2026-11-12 22:23:48 -05:00

15 lines
456 B
Mojo

# probe: is a struct's List field safe to assign in a loop when nothing reads the struct afterwards? (no: the built program crashes on a later pass; with the last line uncommented it runs)
@fieldwise_init
struct Origin(Copyable, Movable):
var hash: List[Int]
def main():
var r = Origin(List[Int]())
for e in range(3):
print("pass", e)
var f = List[Int]()
f.append(2)
r.hash = f.copy()
# print(len(r.hash))