Ignoring later fields instead of overriding when getting dup fields. - #10053
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
PR SummaryLow Risk Overview A Reviewed by Cursor Bugbot for commit a274e99. Bugbot is set up for automated code reviews on this repo. Configure here. |
TomerStarkware
left a comment
There was a problem hiding this comment.
@TomerStarkware reviewed 1 file and all commit messages, and made 1 comment.
Reviewable status: 1 of 2 files reviewed, all discussions resolved (waiting on eytan-starkware).
orizi
left a comment
There was a problem hiding this comment.
@orizi reviewed 1 file.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on eytan-starkware).

Summary
When a struct has duplicate member names, the first declaration is now preserved instead of being overwritten by the last one. This matches the existing behavior for enum variant redefinition. Additionally, a test expectation for member
a's type was corrected from()tocore::felt252.Type of change
Please check one:
Why is this change needed?
When a struct member was redefined (declared more than once), the map insertion via
insertwould overwrite the first declaration with the duplicate. This meant the type and visibility of the last duplicate were retained, even though the duplicate is the one being reported as an error and rejected. This is inconsistent with how enum variant redefinitions are handled.What was the behavior or documentation before?
On a
StructMemberRedefinitionerror, the last duplicate member'sid,ty, andvisibilitywere stored in the members map, discarding the original declaration.What is the behavior or documentation after?
On a
StructMemberRedefinitionerror, the first (original) member declaration is kept in the members map. The duplicate triggers the diagnostic and is discarded, consistent with enum variant redefinition handling.Related issue or discussion (if any)
N/A
Additional context
The
Entry-based approach (Entry::Vacant/Entry::Occupied) replaces the previousinsert-and-check pattern to avoid overwriting the original entry on collision.