feat(t27b): module constants of a struct with str fields - #6324
Merged
Merged
Conversation
A module constant whose struct (or array) type holds a str at a leaf is lowered as a compile-time aggregate (Val::A, one element per field) and written into a frame temporary where memory is needed, as a constant array of strings already was. A module var of such a type stays refused as VarDecl(module, pointer/str/slice). Reference-backed corpus: counted pass 592 -> 597 of 720, mismatch 0. Closes #6323 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
This was referenced Oct 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #6323
Refs #6063
What
ConstDecl(str field)was first in the reference-backed greedy order (tri t27b next): sole blocker on 5 specs the reference passes. Shape:const PIN_CLK: PinAssignment = PinAssignment{ .port_name = "clk", .bank = 35, ... };-- a module constant of a struct withstrfields. t27b kept struct constants as read-only data images, which cannot hold a string's address.Now such a constant (and any array/struct constant with a
strat a leaf) is a compile-time aggregate (Val::A, one element per field: string literal, nested aggregate, read-only image of a str-free aggregate, or constant scalar/enum), written into a frame temporary where memory is needed -- the path constant arrays of strings already took.holds_strnow looks through struct fields;store_constwrites struct fields too;coerce_toaccepts it where a struct is wanted. A modulevarof such a type stays refused asVarDecl(module, pointer/str/slice)(writable data would need relocations).Test:
struct_constants_with_str_fields(fields, defaults, enum and nested struct fields, alias, by-value and by-pointer params, copy-then-mutate, arrays of such structs, runtime index,for, a failing assert with its line). Same source throught27c test-report: 3 pass, 1 fail -- same verdicts.Corpus (
t27b corpus specs --blockers --reference <t27c master e8513e0b5>, 1257 files, reference passes 720)Gain: +5 counted (checked 317 -> 322):
specs/boards/arty_a7.t27,specs/boards/xc7a100t_full.t27,specs/fpga/boards/arty_a7_integration.t27,specs/fpga/boards/qmtech_a100t_integration.t27,specs/port/trios/crates/trios-cli/src/metrics.t27. The sixth reference-passing file,specs/boards/xc7a100t_minimal.t27, is now blocked byVarDecl(module, pointer/str/slice)(modulevar all_pins: [12]PinAssignment) -- not small, left for a later lane.Reference-backed top 5 after: ExprLiteral(char literal) +4, ExprIf +5, StmtExpr +4, StmtFor +4, ExprArrayLiteral +4.
Load average during the runs: 5-60.
docs/reports/t27b_expectations.jsonuntouched (the steward blesses it from the lab).🤖 Generated with Claude Code