✓
Passing This code compiles and runs correctly.
Code
// An EMPTY source block must capture empty text — not consume the
// declaration that follows it.
//
// The defect this pins: `print.blk {` followed by `}` on the next line
// captures from that `}` THROUGH the next block's closing `}`. The
// following declaration is eaten entirely — it never reaches the AST —
// and the empty block's source is the swallowed text, which then prints
// as garbage. Measured 2026-10-03 on koru/stack's first pass: a service
// decl with an empty `{}` body swallowed the next service decl and
// silently dropped its depends_on edge.
//
// Three print.blk flows must exist in the AST (post.sh counts them), and
// the program prints "first", a blank line (the empty block's empty
// source), then "third".
import std/io
std/io:print.blk {
first
}
std/io:print.blk {
}
std/io:print.blk {
third
}
Actual
first
third
Expected output
first
third
Flows
flow ~print.blk click a branch to expand · @labels scroll to their anchor
print.blk (source: first)
flow ~print.blk click a branch to expand · @labels scroll to their anchor
print.blk (source: )
flow ~print.blk click a branch to expand · @labels scroll to their anchor
print.blk (source: third)
Test Configuration
MUST_RUN
Post-validation Script:
#!/bin/bash
# Structural pin: the input file contributes three print.blk flows to
# program.ast.json. Two means the empty block swallowed the following
# declaration — the defect this test exists to refuse.
set -e
COUNT=$(python3 -c "
import json
ast = json.load(open('program.ast.json'))
n = 0
def walk(o):
global n
if isinstance(o, dict):
loc = o.get('location') or {}
inv = (o.get('node') or {}).get('invocation') if isinstance(o.get('node'), dict) else None
if inv and '$KORU_INPUT' in str(loc.get('file', '')):
p = inv.get('path', {})
if p.get('segments') == ['print', 'blk']:
n += 1
for v in o.values():
walk(v)
elif isinstance(o, list):
for v in o:
walk(v)
walk(ast)
print(n)
")
[ "$COUNT" = "3" ] || { echo "FAIL: expected 3 print.blk flows from input, got $COUNT — empty source block ate a declaration"; exit 1; }