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/loopbound.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 / loopbound.osc` 34 lines ยท 754 bytes Raw Blame History 1 // entry: count_to count_for else_returns 2 // exactly N while iterations run; iteration N+1 traps LOOP_BOUND. 3 // expect-run: count_to 10 -> 10 4 // expect-run: count_to 11 -> trap=LOOP_BOUND 5 // expect-run: count_to 0 -> 0 6 // expect-run: count_for 5 -> 9 7 // expect-run: else_returns 1 -> 12 8 // expect-run: else_returns 0 -> 0 9 fn count_to(n: u32) -> u32 { 10 let mut i: u32 = 0; 11 while i < n bound 10 { 12 i = i + 1; 13 } 14 return i; 15 } 16 17 fn count_for(k: i64) -> i64 { 18 let mut s: i64 = 0; 19 for i in -3 .. 3 { 20 s = s + i + k / 2; 21 } 22 return s; 23 } 24 25 fn else_returns(c: u8) -> u8 { 26 let a: own [u8; 3] = alloc(4); 27 let mut x: u8 = 0; 28 if c > 0 { 29 x = 1; 30 } else { 31 return 0; 32 } 33 return a[0] * 3 * x; 34 }