Skip to content

feat(t27b): lower if-expressions natively; refuse what t27c misprints - #6328

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

gHashTag merged 1 commit into
masterfrom
claude/t27b-exprif

Conversation

@gHashTag

@gHashTag gHashTag commented Oct 5, 2026

Copy link
Copy Markdown
Owner

Closes #6327
Refs #6063

What

  • if used as a value -> IR Select { cond, then, els }. Codegen emits a branch, not a csel, so only the taken arm runs: a trap or call in the other arm never fires, as in Zig. Interpreter (eval.rs), AArch64 (codegen.rs, spilled destinations stored on both paths), and the differential fuzzer (random Select checked against the interpreter oracle).
  • Arms take the result type (return, typed binding, parameter) or their peer type; string and struct arms select an address; a comptime-known condition lowers only the taken arm.
  • Refused by name, never guessed:
    • ExprIf(no else)
    • ExprIf(comptime arms): Zig cannot type two comptime_int arms behind a runtime condition.
    • ExprIf(left operand): t27c prints (if (c) a else b) + 1 as if (c) a else b + 1, and the same for (if ...).x and (if ...)[i]. Zig reads what follows into the else arm, so no lowering of the source can match the reference. Checked: this probe passes in t27b and fails in t27c test-report.
  • Test if_expression_runs_only_the_taken_arm in cli/t27b/tests/source.rs. Its module gives the same per-test verdict under t27c test-report: 5 pass and taken_arm_traps fails in both.

Corpus (t27b corpus specs --blockers --reference <t27c from origin/master a82d61dcd> --reference-cache <own>)

before after
pass (all tests pass) 326 329
pass_vacuous 283 284
fail 6 6
rejected 599 595
front-end error 40 40
mismatch 0 0
timeout 3 3
counted /720 597 601
  • Gained, checked pass (tests 2020 -> 2033): port/trinity/src/cli/health_check.t27 (3), port/trinity/src/tri/gen_relu.t27 (4), port/trios/crates/trios-cli/src/cmd/agent.t27 (4).
  • Gained, pass_vacuous: port/trios/crates/trios-sacred/rings/SC-01/src/lib.t27.
  • No reference-passing file is refused by ExprIf(comptime arms). The only one refused by ExprIf(left operand) is port/fpga/verilog/ternary_mac_demo_top.t27, which is also blocked by a tuple and has no tests.

Next greedy steps after this PR: char literal +5, StmtExpr +4, StmtFor +4, ExprArrayLiteral +4, type [N]T +8.

Seen, not fixed here: t27c prints -(x - y) as -x - y. t27b lowers the source meaning, so any test that reaches that shape is a reference bug.

docs/reports/t27b_expectations.json is untouched.

🤖 Generated with Claude Code

An `if` used as a value becomes IR `Select { cond, then, els }`, a branch
in codegen so only the taken arm runs (a trap in the other never fires).
Arms take the result type or their peer type; string and struct arms
select an address; a comptime condition lowers only its arm.

Refused by name: ExprIf(no else), ExprIf(comptime arms), and
ExprIf(left operand): t27c prints `(if (c) a else b) + 1` without the
parentheses, so Zig reads the `+ 1` into the else arm.

Corpus vs t27c reference: counted 597 -> 601 of 720, checked passes
326 -> 329, mismatch 0.

Closes #6327
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 01:36:22 UTC

Summary

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

These columns do not partition: 11 + 33 + 0 + 0 = 44, and there are 45 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).

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 if-expressions (ExprIf) natively, refuse what the reference misprints

1 participant