✓
Passing This code compiles and runs correctly.
Code
// PINS the grid's bounds floor, PER AXIS.
//
// An index outside the grid traps, naming the grid and — for a dimensioned grid
// — WHICH AXIS escaped. `[x, y]` with a good x and a bad y is the common slip,
// and "index out of range" alone would not locate it.
//
// Ruled 2026-08-03: trapping mirrors the store's stale-handle floor. Fail loud,
// never silently address a neighbouring cell. WRAPPING IS THE PROGRAM'S
// DECISION and belongs in the source as an explicit `% size` where a reader can
// see it — a spatial hash wants exactly that and should say so rather than have
// the container guess on its behalf.
//
// The check is a floor, not a permanent tax: an index the compiler can prove in
// range needs none, and a sweep arm over a grid is exactly that case, since the
// loop builds the index from `0..size`. Same floor-then-prove-away arc the
// handle check follows.
import std/io
import std/grid
std/grid:new(lights, dimensions: 4x5) { on: 0[i64] }
std/io:print.ln("before")
std/grid:stored { lights[1, 9].on: 1 }
std/io:print.ln("unreachable")
Actual
before
thread 338417216 panic: std/grid: y out of range for grid 'lights' (rows 4)
???:?:?: 0x105092407 in _output_emitted.main_module.__KoruGridT_lights.__koru_at2__anon_19369 (???)
???:?:?: 0x105091c07 in _output_emitted.main_module.__grid_write_L24_a3da_event.__koru_handler_impl (???)
???:?:?: 0x10509188f in _output_emitted.main_module.flow1 (???)
???:?:?: 0x105091757 in _output_emitted.main (???)
???:?:?: 0x10509166b in _main (???)
???:?:?: 0x18eec7dff in ??? (???)
???:?:?: 0x0 in ??? (???)
Flows
flow ~new click a branch to expand · @labels scroll to their anchor
new (expr: lights, dimensions: 4x5, source: on: 0[i64])
flow ~print.ln click a branch to expand · @labels scroll to their anchor
print.ln (expr: "before")
flow ~stored click a branch to expand · @labels scroll to their anchor
stored (source: lights[1, 9].on: 1)
flow ~print.ln click a branch to expand · @labels scroll to their anchor
print.ln (expr: "unreachable")
Test Configuration
MUST_RUN