Skip to content

feat(t27b): lower for over a range and for x in xs (Closes #6349) - #6350

Merged
gHashTag merged 1 commit into
masterfrom
claude/t27b-forloop
Oct 5, 2026
Merged

gHashTag merged 1 commit into
masterfrom
claude/t27b-forloop

Conversation

@gHashTag

@gHashTag gHashTag commented Oct 5, 2026

Copy link
Copy Markdown
Owner

Closes #6349
Refs #6063

What

cli/t27b/src/lower.rs lowers the for shapes the reference-backed blocker list ranked next (StmtFor +4, StmtFor(range) +3, plus StmtForRange):

  • for (a..b) |i|, for i in a..b, for (i in a..=b), for _ in a..b: Zig's semantics -- both bounds coerced to usize and evaluated once (a first), the length b - a computed with a checked subtraction before the first iteration (Zig panics with integer overflow when b < a; checked against zig test), the capture a usize constant per iteration. continue runs the step.
  • for x in xs: t27c's parser copies the loop variable into the node name, which t27b read as a labelled loop (that was the provider-error-classifier.t27 "labelled loop"). The parser builds no labelled loops; a name equal to the sole capture is now the collection loop, any other name stays refused.
  • Refused with specific names where there is no reference verdict to match or t27b does not lower it yet: StmtFor(multi-object) (for (xs, ys) |x, y|), a comptime-reversed range (range 3..1 runs backwards), a signed bound (type mismatch), a negative literal bound (literal out of range) -- the last three are compile errors under t27c test-report.

Test for_over_a_range in cli/t27b/tests/source.rs (interpreter + JIT): ranges PASS, nested_ranges PASS, reversed_range_traps FAIL (integer overflow at the loop line) -- the same verdicts t27c test-report gives the same source. bench_unlowerable_body_names_its_construct now uses a multi-object loop as its unlowerable construct (its old for (0..10) body lowers now and is refused as a type mismatch instead, as Zig refuses @as(u32, usize)).

Measure

t27b corpus specs --blockers --reference <t27c> --reference-cache <own cache>, t27c built from origin/master e0e806a, fixed copies of the t27b binary before and after, load average 25-170 during the runs.

before after
pass (with tests) 343 351
pass_vacuous 285 285
fail 9 9
rejected (blocked) 577 569
front-end error 40 40
mismatch 0 0
timeout 3 3
counted (t27b pass where reference passes) / 720 615 623
checked pass (with tests) where reference passes 338 346

Reference: pass 720, blocked 509, fail 26, timeout 2 (same in both runs, cached).

Newly passing (all reference-pass, every test run): provider-error-classifier.t27 (18 tests), gen_w379.t27 (7), gen_caesar.t27 (2), gen_mock.t27 (5), gen_neuron.t27 (4), gen_rle.t27 (5), gen_test_runner.t27 (4), trios-doctor/src/main.t27 (3).

No file anywhere in specs/ is blocked by StmtFor(range) or StmtForRange any more. What is left of the family: StmtFor(multi-object) in 4 files (2 reference-passing, gen_cross_entropy and gen_linear_regression, both also blocked by other constructs) and StmtFor "more than one iterable or capture" in 3 reference-blocked files.

Reference-backed greedy top 5 after: StmtExpr +4, ExprLiteral(negative literal) +4, ExprUnary(try) statement +3, ExprSwitch +4, type f32 +3.

docs/reports/t27b_expectations.json is untouched.

🤖 Generated with Claude Code

for (a..b) |i| and for i in a..b lower to a counted loop with Zig's
semantics: usize bounds evaluated once, length b - a checked before
the first iteration, capture a usize constant. for x in xs no longer
reads the loop variable as a label. Multi-object loops are refused as
StmtFor(multi-object).

t27b corpus specs --reference: counted 615 -> 623 / 720, checked
338 -> 346, mismatch 0.

Closes #6349
Refs #6063

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-10-05 02:47:13 UTC

Summary

Status Count
Total Open PRs 46
PRs with Failing Checks 34
PRs with All Checks Green 12
READY 11
FAILING 34
PENDING 0
NO CHECKS YET 0

These columns do not partition: 11 + 34 + 0 + 0 = 45, and there are 46 open PRs. A PR is being counted twice or not at all.

Seal Status

  • ⚠️ STALE -- sha256(compiler.rs)=8597b6ded596 != manifest seal=87e5cbd3ad94.
    The committed NMSE numbers were certified against an older compiler.rs.
    Run scripts/reseal-check.sh locally for the two-step reseal command (advisory; not a merge gate).

@gHashTag
gHashTag merged commit f25dbee into master Oct 5, 2026
29 of 31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

t27b: lower for over a range (for (a..b) |i|, for i in a..b, for x in xs)

1 participant