✓
Passing This code compiles and runs correctly.
Code
// PINS: `std/grid:slice(name) { grid.field }` — borrows a column's backing
// array as a raw slice. Reads `s[i]` are generic indexing (they splice
// verbatim — no __koru_at call, no field access). Writes `stored { s[i]:
// v }` emit a direct `s[i] = v` assignment — the grid's per-access floor
// is dropped by the borrow's own contract: the program asked for the raw
// view, so index obligations move to the program. The value is still
// typed by the borrowed column's declared type.
//
// std/grid:new(g, size: 4) { c: 0[u8] }
// std/grid:slice(s) { g.c }
//
// Value oracle: fill 10,11,12,13 through the borrow; read s[0]=10,
// s[3]=13, s.len=4 back.
import std/io
import std/grid
std/grid:new(g, size: 4) { c: 0[u8] }
std/grid:slice(s) { g.c }
std/grid:stored { s[0]: 10, s[1]: 11, s[2]: 12, s[3]: 13 }
|> std/io:print.ln("a={{ s[0]:d }} b={{ s[3]:d }} len={{ s.len:d }}")
Actual
a=10 b=13 len=4
Expected output
a=10 b=13 len=4
Flows
flow ~new click a branch to expand · @labels scroll to their anchor
new (g, size: 4, source: c: 0[u8])
flow ~slice click a branch to expand · @labels scroll to their anchor
slice (s, source: g.c)
flow ~stored click a branch to expand · @labels scroll to their anchor
stored (source: s[0]: 10, s[1]: 11, s[2]: 12, s[3]: 13)
Test Configuration
MUST_RUN
Post-validation Script:
#!/bin/sh
# A slice borrow emits `const s = __koru_grid_g.c[0..]` next to the grid in
# the module; writes through it emit `s_arg[...] = v` in the write unit
# with the slice threaded as a []u8 argument — NO __koru_at anywhere on
# the borrowed column; reads `s[i]` splice verbatim (generic indexing).
EMIT=$(ls output_emitted.zig 2>/dev/null || ls emitted.zig 2>/dev/null)
grep -q "const s = __koru_grid_g.c\[0..\];" "$EMIT" || { echo "slice borrow const missing"; exit 1; }
grep -q "__koru_gs0: \[\]u8" "$EMIT" || { echo "slice not threaded as arg"; exit 1; }
grep -qE "__koru_gs[0-9]+\[@as\(usize" "$EMIT" || { echo "bare slice store missing"; exit 1; }
! grep -q "koru_grid_g.c\[.*at(" "$EMIT" || { echo "borrowed access still pays the floor"; exit 1; }
exit 0