Skip to content

t27b: an array length written as a constant expression (Closes #7347) - #7382

Draft
gHashTag wants to merge 8 commits into
masterfrom
claude/t27b-lane1-arr-type
Draft

gHashTag wants to merge 8 commits into
masterfrom
claude/t27b-lane1-arr-type

Conversation

@gHashTag

@gHashTag gHashTag commented Oct 7, 2026 •

Copy link
Copy Markdown
Owner

Closes #7347. Refs #6063.

What

t27b refused an array type whose length is not a bare literal or a bare constant name (type [N]T), for example [W*H]u8 or [N]u8 where const N = H * 5. The reference compiles these, so the refusal blocked files the reference passes.

t27b now folds the length at compile time: integer literals, module constants (typed or untyped, including one defined by another expression), + - *, the wrapping forms, parentheses and unary minus. A length that does not fold to a non-negative integer is still refused: a division, a call, a run-time value, a negative length, or a typed constant that overflows its type. Typed module constants fold the same way, so const R = Q +% 10 with Q: u8 = 250 is 4. const OV = B + 100 with B: u8 = 200 is refused, matching the reference's refusal.

Evidence (lab, --jobs 2, no interpreter fallback, no skipped tests)

  • Dogfood spec specs/tri/t27b/conformance/array_len_expr.t27: 5 pass, 0 vacuous in the reference; the same 5 in t27b, 16 runtime asserts.
  • 7 mutants each fail the same tests in both. Of 22 probes, 9 pass in both, 2 fail in both, and 8 are blocked by the reference and refused by t27b. The other 3 are honest t27b refusals where the reference passes: a length using /, a length using a call, and a 50 KB local array over the frame limit.
  • cargo test -p t27b: 14 suites, 128 passed, 0 failed (at 7a7688c).
  • Lab corpus, branch 8c677e1 vs master e45ba56: t27b pass where the reference passes 818 -> 819, mismatch 0, reference_disagree 0. The only other change is routes/memory.t27, which now stops at FnDecl(frame size) instead of type [N]T.
  • Ledger docs/reports/t27b_expectations.json recounted after merging master 05e633d (pass 534, vacuous 262, not_pass 25); no duplicate paths.

Foreign code

cli/t27b/src/lower.rs and cli/t27b/tests/source.rs are Rust. The owner approved foreign Rust in cli/t27b for #6063 and asked agents to set the owner-approved-foreign label themselves. Both files are listed in tools/policy/foreign-exceptions.txt.

NOW entry: docs/now/2026-10-07-t27b-array-len-expr.md.

🤖 Generated with Claude Code

gHashTag and others added 7 commits October 7, 2026 14:38
[W + 1]u8, [(W + 1) * 2]u16, [H * 2]u64 with H: u32: the length text is
parsed back and folded as a module constant is, as Zig folds the text t27c
prints. Run-time names, calls and negative lengths are refused.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ts (Closes #7347)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…oses #7347)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rr-type

# Conflicts:
#	tools/policy/foreign-exceptions.txt
…loses #7347)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…essions (Closes #7347)

array_len_expr.t27 moves to pass; routes/memory.t27 now stops at
FnDecl(frame size). Lab corpus at --jobs 2: 818 -> 819, mismatch 0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rr-type

# Conflicts:
#	docs/reports/t27b_expectations.json
This was referenced Oct 7, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

owner-approved-foreign Owner-approved exception to the only-t27 rule: hand-written foreign code allowed in this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

t27b: an array length that is a compile-time expression ([N + 1]T)

1 participant