Skip to content

feat(t27b): lower char literals natively as comptime_int - #6331

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

gHashTag merged 1 commit into
masterfrom
claude/t27b-charlit

Conversation

@gHashTag

@gHashTag gHashTag commented Oct 5, 2026

Copy link
Copy Markdown
Owner

Closes #6330
Refs #6063

What

ExprLiteral(char literal) was first in the reference-backed greedy order (+5 files). The t27c lexer makes a char literal from one byte or a backslash plus one byte, the parser keeps the quotes, and gen-zig prints it verbatim, so Zig types it as comptime_int; t27c's optimizer never folds or propagates it (is_literal reads integers only). t27b now lowers it to an untyped integer constant (Val::Ct).

Refused by name, each checked against t27c test-report (all three BLOCKED there):

  • ExprLiteral(char escape): '\0' and escapes outside \n \r \t \\ \' \" (Zig: "invalid escape character").
  • ExprLiteral(char byte): a raw control byte inside the quotes (Zig: "character literal contains invalid byte").
  • ExprBinary(char literal << >>): a shift by a typed or runtime amount; t27c prints 'a' << @intCast(k) (Zig: "unable to cast runtime value to 'comptime_int'").

Test char_literals_are_comptime_ints in cli/t27b/tests/source.rs: under t27c test-report the same source gives digits_and_case PASS, escapes PASS, overflow_traps FAIL; t27b gives the same, with the overflow trap at line 21. The blockers fixture now uses '\0' as its unsupported literal.

Corpus (t27b corpus specs --blockers --reference <t27c from origin/master 634b3ff26>)

before after
pass 329 335
pass_vacuous 284 284
fail 6 8
rejected 595 587
front-end error 40 40
mismatch 0 0
timeout 3 3
counted (t27b pass where reference passes) / 720 601 606
checked pass with tests, reference passes 309 314

Gained (reference pass, t27b pass): TbCheck_new, gen_w380, mcp-wrapper, railway_create_project, gen_color. The two new fails agree with the reference or have none: specs/tri/search/pattern.t27 fails wildcard_match_no_match in both, 10 other tests pass in both; specs/port/scripts/gen_w368.t27 is BLOCKED in the reference (redeclaration of local variable 'k') and its t27b failure is the spec's own test logic (the second scan loop starts where the first ended). queen-lease.t27 now passes in t27b but is BLOCKED in the reference ('_' used as an identifier), so it is not counted.

Load average during the runs: 20-130 (local Mac).

docs/reports/t27b_expectations.json is not touched here: six of its ExprLiteral(char literal) rows will read as UNEXPECTED PASS or a new blocker; the steward re-blesses.

Seen, not fixed here (t27c)

  • A module-level const X: u8 = 'a'; loses its value: gen prints const X: u8; (t27b already refuses it as ConstDecl ... has no value).
  • A char switch arm prints as .'a' =>.

🤖 Generated with Claude Code

A char literal is one byte or a backslash plus one byte; t27c prints it
verbatim and Zig types it as comptime_int, so t27b lowers it to an
untyped integer constant. What Zig rejects is refused by name:
ExprLiteral(char escape) for '\0', ExprLiteral(char byte) for a raw
control byte, ExprBinary(char literal << >>) for a shift by a typed or
runtime amount.

Corpus with --reference: counted 601 -> 606 of 720, mismatch 0.

Closes #6330

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:56:46 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 char literals natively ('a', '\n') as comptime_int

1 participant