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/shortcircuit.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 / shortcircuit.osc` 20 lines ยท 592 bytes Raw Blame History 1 // entry: safe_div guarded_index either 2 // expect-run: safe_div 9 0 -> 0 3 // expect-run: safe_div 9 2 -> 1 4 // expect-run: guarded_index 4 -> trap=BOUNDS 5 // expect-run: guarded_index `18446744073709551615` -> 2 6 // && and || short-circuit: the right side runs only when needed. 7 fn safe_div(a: i32, b: i32) -> bool { 8 return b != 0 && a / b > 3; 9 } 10 11 fn guarded_index(i: i64) -> i64 { 12 let a: own [i64; 4] = alloc(9); 13 if i >= 0 && i < 4 && a[i] == 9 { return 1; } 14 if i < 0 || a[i] > 0 { return 2; } 15 return 3; 16 } 17 18 fn either(a: u8, b: u8) -> bool { 19 return a == 0 || 200 / a > b; 20 }