omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
omega-mv / tests / compiler / progs / arena_dtor.osc
| 1 | // entry: adtor |
| 2 | // OSC-2 arenas: deterministic destruction order. At the end of an arena block |
| 3 | // the unique owners declared inside it are released first (reverse |
| 4 | // declaration order), then the arena is destroyed (one REGION_DESTROY frees |
| 5 | // all its objects). Nested: inner arena before outer. The event order is |
| 6 | // asserted by test_osc_compiler (arena destruction order). |
| 7 | // expect-run: adtor 1 -> 8 |
| 8 | fn adtor(k: u32) -> u32 { |
| 9 | let mut s: u32 = 0; |
| 10 | let u: own [u32; 1] = alloc(k); |
| 11 | arena outer bound 3 { |
| 12 | let a: own [u32; 1] in outer = alloc(1); |
| 13 | arena inner bound 2 { |
| 14 | let b: own [u32; 2] in inner = alloc(2); |
| 15 | let v: own [u32; 1] = alloc(3); |
| 16 | s = a[0] + b[1] + v[0]; |
| 17 | } |
| 18 | let w: own [u32; 1] = alloc(1); |
| 19 | s = s + w[0]; |
| 20 | } |
| 21 | return s + u[0]; |
| 22 | } |