✓
Passing This code compiles and runs correctly.
Code
// NAME COLLISION — a store whose identifier collides with a koru_std
// local must still elide handle machinery. The handle gate walks the
// whole program scanning text slots for `store[` index expressions and
// bare row-binding reads; koru_std's own bodies are full of both on
// locals that can never name a program store — `.items[` (the
// ArrayList idiom all over store.new.kz), `names[i] = field.name`
// (store.kz), `data[wi]` (field.kz), `fields[i]` (interpreter.run).
// Before the gate scoped its scan to modules that can actually name
// the store — and excluded `.name[` member access from the match —
// every one of these stores kept its hslot freelist, generation table,
// and per-insert handle stores purely because of the identifier.
// `items`/`names`/`data`/`fields` below are all observation-free and
// must emit lean: no hslot, no resolve, and the counted fill bulks.
import std/io
import std/store
import std/control
std/store:new(items, capacity: 8) { on: i64 }
std/store:new(names, capacity: 8) { on: i64 }
std/store:new(data, capacity: 8) { on: i64 }
std/store:new(fields, capacity: 8) { on: i64 }
for(0..4)
! each i |> std/store:insert(items) { on: @intCast(i) }
for(0..4)
! each i |> std/store:insert(names) { on: @intCast(i * 2) }
for(0..4)
! each i |> std/store:insert(data) { on: @intCast(i * 3) }
for(0..4)
! each i |> std/store:insert(fields) { on: @intCast(i * 4) }
std/store:query(items)
! query e |> std/io:print.ln("items {{ e.on:d }}")
std/store:query(names)
! query e |> std/io:print.ln("names {{ e.on:d }}")
std/store:query(data)
! query e |> std/io:print.ln("data {{ e.on:d }}")
std/store:query(fields)
! query e |> std/io:print.ln("fields {{ e.on:d }}")
Actual
items 0
items 1
items 2
items 3
names 0
names 2
names 4
names 6
data 0
data 3
data 6
data 9
fields 0
fields 4
fields 8
fields 12
Expected output
✓ Zig✓ JavaScriptitems 0
items 1
items 2
items 3
names 0
names 2
names 4
names 6
data 0
data 3
data 6
data 9
fields 0
fields 4
fields 8
fields 12
Flows
flow ~new click a branch to expand · @labels scroll to their anchor
new (items, capacity: 8, source: on: i64)
flow ~new click a branch to expand · @labels scroll to their anchor
new (names, capacity: 8, source: on: i64)
flow ~new click a branch to expand · @labels scroll to their anchor
new (data, capacity: 8, source: on: i64)
flow ~new click a branch to expand · @labels scroll to their anchor
new (fields, capacity: 8, source: on: i64)
flow ~for click a branch to expand · @labels scroll to their anchor
for (0..4)
flow ~for click a branch to expand · @labels scroll to their anchor
for (0..4)
flow ~for click a branch to expand · @labels scroll to their anchor
for (0..4)
flow ~for click a branch to expand · @labels scroll to their anchor
for (0..4)
flow ~query click a branch to expand · @labels scroll to their anchor
query (items)
flow ~query click a branch to expand · @labels scroll to their anchor
query (names)
flow ~query click a branch to expand · @labels scroll to their anchor
query (data)
flow ~query click a branch to expand · @labels scroll to their anchor
query (fields)
Test Configuration
MUST_RUN LANGUAGES: zig js
Post-validation Script:
#!/bin/bash
# Emitted-shape oracle for the name-collision gate fix. koru_std's own
# module bodies index locals named `items` (`.items[`, the ArrayList
# idiom), `names` (`names[i] = field.name`, store.kz), `data`
# (`data[wi]`, field.kz) and `fields` (`fields[i]`, interpreter.run) —
# text a whole-program name scan cannot distinguish from an index on a
# user store of the same name. The gate now scans only items that can
# textually name the store (non-koru_std modules plus the store's own
# home) and excludes `.name[` member access, so all four stores below
# must be lean: zero handle machinery anywhere in the file, and each
# counted fill must have lowered to bulk append.
set -u
if [ ! -f output_emitted.zig ]; then
echo "FAIL: no output_emitted.zig"
exit 1
fi
# --- no handle machinery at all: four stores, all observation-free ---
if grep -q 'hslot\|__koru_resolve\|__koru_handle_of\|__koru_row_of' output_emitted.zig; then
echo "FAIL: a stdlib-named store kept handle machinery"
exit 1
fi
# --- every counted fill lowered to bulk append ---
for s in items names data fields; do
if ! grep -q "__koru_store_${s}.on\[__koru_bulk_base + __koru_bulk_j\]" output_emitted.zig; then
echo "FAIL: $s fill did not bulk-lower"
exit 1
fi
if ! grep -q "__koru_store_${s}.len += __koru_bulk_n" output_emitted.zig; then
echo "FAIL: $s missing the single len += n"
exit 1
fi
done
# --- JS lane: correct per-row lowering, no Zig bulk text ---
if [ -f output_emitted.js ]; then
if grep -q '__koru_bulk' output_emitted.js; then
echo "FAIL: JS lane emitted bulk append text"
exit 1
fi
fi
echo "PASS: stores named like koru_std locals stay lean and bulk"
exit 0