aboutsummaryrefslogtreecommitdiff
path: root/tests/conformance/6-ownership/drop_gc_self_capture.zc
blob: 444211d282a88058c68997123c7ad35a5e0cca97 (plain) (blame)
1
2
3
4
5
6
7
// expect: drop 3 0/
// destructors 6.15.3: a value its own drop reaches (the closure captures it) is a cycle of one, so the collector still finalizes it once, then frees it
include rt;
word g;
unchecked fn make() { word p = heap(3); word q = p; p.drop = fn() { rt.put_s("drop "); rt.put_n(*q); rt.put_c(32); }; g = p; return 0; }
fn main() { make(); g = 0; rt.gc(); rt.gc(); rt.gc(); rt.put_n(rt.dcount); rt.put_c(10); return 0; }
// zc0: skip