1import core/diag
2import core/mem
3
4exercise: () -> (ok: bool) ! mem.out_of_bounds =
5 ok = false
6 mut value := diag.new(capacity: 1)
7 return when diag.stored(addr value) <> 0 or diag.dropped(addr value) <> 0
8 _ = diag.note_at(addr value, usize(0)) else (problem)
9 ok = problem == mem.out_of_bounds
10 return
11 end
12end exercise
13
14public main: () -> (code: i32) =
15 code = 1
16 ok := exercise() else false
17 if ok then
18 code = 42
19 end if
20end main