Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/tests/compiler/progs/df_nested.osc # 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 Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / tests / compiler / progs / df_nested.osc` 34 lines ยท 1030 bytes Raw Blame History 1 // entry: f g 2 // OSC-3 item 3 (drop flags): moves at different depths of nested ifs and an 3 // else-if chain; returns inside branches while another owner is maybe-moved 4 // (the return's release of that owner is guarded by its flag). 5 fn take(x: own [u32; 2]) -> u32 { return x[0] + x[1]; } 6 7 fn f(k: u32) -> u32 { 8 let a: own [u32; 2] = alloc(1); 9 let b: own [u32; 2] = alloc(2); 10 let mut r: u32 = 0; 11 if k > 2 { 12 if k > 5 { r = take(a); } else { r = take(b); } 13 } else if k == 1 { 14 r = take(a) + take(b); 15 } 16 return r + 100; 17 } 18 19 fn g(k: u32) -> u32 { 20 let a: own [u32; 2] = alloc(k & 7); 21 let b: own [u32; 2] = alloc(3); 22 if k > 4 { let m: own [u32; 2] = a; b[0] = m[0]; } 23 if k > 6 { return b[0] + 1; } 24 if k == 2 { let n: own [u32; 2] = b; return n[1]; } 25 return b[1] + 10; 26 } 27 // expect-run: f 7 -> 102 28 // expect-run: f 4 -> 104 29 // expect-run: f 1 -> 106 30 // expect-run: f 0 -> 100 31 // expect-run: g 7 -> 8 32 // expect-run: g 5 -> 13 33 // expect-run: g 2 -> 3 34 // expect-run: g 0 -> 13