bug fix(semantic): Support struct-update (..base) syntax in const expressions. - #10136
Conversation
PR SummaryLow Risk Overview Validation walks the base expression like other const subexpressions. Evaluation evaluates the base to a Reviewed by Cursor Bugbot for commit d98cfb7. Bugbot is set up for automated code reviews on this repo. Configure here. |
6831725 to
342ba4a
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6831725608
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
TomerStarkware
left a comment
There was a problem hiding this comment.
@TomerStarkware reviewed 2 files and all commit messages, and made 1 comment.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on eytan-starkware and orizi).
342ba4a to
c78a1d7
Compare
c78a1d7 to
0389587
Compare
fd4fc03 to
f241872
Compare
0389587 to
fa8c243
Compare
TomerStarkware
left a comment
There was a problem hiding this comment.
@TomerStarkware reviewed 2 files and all commit messages, and made 1 comment.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on eytan-starkware).
f241872 to
fafd3c2
Compare
fa8c243 to
3251d29
Compare
fafd3c2 to
7ff5282
Compare
3251d29 to
d98cfb7
Compare
orizi
left a comment
There was a problem hiding this comment.
@orizi reviewed 1 file and all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on eytan-starkware).

Summary
Adds support for struct update syntax (
Foo { field: value, ..base }) in constant expressions. Previously,ConstantEvaluateContextonly handled struct constructors with no base struct (base_struct: None), causing struct update syntax to be unsupported inconstcontexts. Now, the base struct expression is validated and evaluated, and its member values are used as fallbacks for any fields not explicitly specified in the constructor.Type of change
Please check one:
Why is this change needed?
Struct update syntax (
Point { y: 20, ..BASE }) was not usable inconstdeclarations. The constant evaluator would silently skip or fail on any struct constructor that included a base struct, leaving users unable to derive one constant struct from another using this syntax.What was the behavior or documentation before?
Struct update syntax in
constexpressions was not supported. The evaluator only matchedExprStructCtorwithbase_struct: None, so any use of..basein a constant struct constructor would not be evaluated correctly.What is the behavior or documentation after?
Struct update syntax is now valid in
constexpressions. The base struct is validated and evaluated, and its member values fill in any fields not explicitly provided. Chained updates (e.g., deriving a constant from another already-updated constant) are also supported, as demonstrated by the new test:Related issue or discussion (if any)
Additional context
The base struct's evaluated
ConstValue::Structvalues are indexed by member order position and used as fallbacks via.or_else(|| Some(base_members?[index]))when a field is not explicitly listed in the constructor.