Skip to content

EmitHull: fix default pattern handling#342

Merged
mbenke merged 1 commit intomainfrom
mbenke/fix-match-default
Mar 24, 2026
Merged

EmitHull: fix default pattern handling#342
mbenke merged 1 commit intomainfrom
mbenke/fix-match-default

Conversation

@mbenke
Copy link
Copy Markdown
Collaborator

@mbenke mbenke commented Mar 24, 2026

  • Fix missing variable substitution for default (variable) patterns in match statements. When a match arm uses a catch-all variable pattern (e.g. | x => ...), the variable was not being bound to the scrutinee value, leaving it unresolved in the generated code.
  • Two call sites were affected:
    • emitWordAlt: default pattern variable in word matches was unbound
    • emitEqn: default pattern variable in sum type matches was silently dropped
  • Add test cases for both word and sum type match defaults
    • word-match-default.solc — word scrutinee with literal + default pattern
    • sum-match-default.solcOption(word) scrutinee with constructor + default pattern

…d emitEqn

- Binds the default variable to the scrutinee in the substitution map ecSubst inside emitWordAlt and emitEqn.
- This ensures Yul inline assembly inside default match branches can reference the bound variable instead of failing with 'undefined identifier'.
- Adds test cases word-match-default.solc and sum-match-default.solc.
@mbenke mbenke requested a review from rodrigogribeiro March 24, 2026 08:52
@mbenke mbenke changed the base branch from main to mbenke/yul-renamer March 24, 2026 08:53
@mbenke
Copy link
Copy Markdown
Collaborator Author

mbenke commented Mar 24, 2026

This should be merged to main, but after #341

Copy link
Copy Markdown
Collaborator

@rodrigogribeiro rodrigogribeiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@mbenke mbenke changed the base branch from mbenke/yul-renamer to main March 24, 2026 12:01
@mbenke mbenke merged commit 45fb876 into main Mar 24, 2026
4 checks passed
@mbenke mbenke deleted the mbenke/fix-match-default branch March 24, 2026 12:02
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.

2 participants