✓
Passing This code compiles and runs correctly.
Code
// PINS: `$mod.` rewrites even immediately after the range operator — the
// splice path AND the module-handler path both walk the same boundary check
// (this file's top-level consumer exercises the splice; the module's own
// handler emission exercises the strip). See lib/ring.kz for the shape.
import std/io
import app/lib/ring
app/lib/ring:push(b: 7)
! saw v |> std/io:print.ln("saw {{ v:d }}")
| count n |> std/io:print.ln("count {{ n:d }}")
app/lib/ring:push(b: 9)
! saw v |> std/io:print.ln("saw {{ v:d }}")
| count n |> std/io:print.ln("count {{ n:d }}")
Actual
saw 7
count 1
saw 7
saw 9
count 2
Expected output
saw 7
count 1
saw 7
saw 9
count 2
Flows
flow ~push click a branch to expand · @labels scroll to their anchor
push (b: 7)
flow ~push click a branch to expand · @labels scroll to their anchor
push (b: 9)
Imported Files
// A zig proc slicing its own module state with `[0..$mod.len]` — the `$mod.`
// spelling the KORU112 rule sanctions, in the one position the rewriter's
// boundary check used to miss: directly after the range operator. The check
// excludes a preceding '.' to protect member chains (`x.std.`), but `..` is
// not member access — it is the range operator, and `$` can never continue a
// member chain in Zig anyway. Before the fix the emitted text kept `$mod.`
// verbatim inside the slice:
// error: expected ']', found invalid bytes
//
// Found in koru-examples/kopium's SSE framing buffer
// (`sse_buf[0..$mod.sse_len]`). Reproduced here with no curl, no SSE.
const std = @import("std");
var ring: [8]u8 = undefined;
var len: usize = 0;
~pub tor push { b: i64 }
! saw i64
| count i64
~proc push|zig {
if ($mod.len < $mod.ring.len) {
$mod.ring[$mod.len] = @intCast(b);
$mod.len += 1;
}
for ($mod.ring[0..$mod.len]) |v| {
saw(@as(i64, @intCast(v)));
}
return .{ .count = @intCast($mod.len) };
}
Test Configuration
MUST_RUN