Skip to content

Fix parser failure for inside expression in module-level if generate construct#123

Merged
dalance merged 2 commits intodalance:masterfrom
pointerliu:fix-gen-inside
Mar 30, 2026
Merged

Fix parser failure for inside expression in module-level if generate construct#123
dalance merged 2 commits intodalance:masterfrom
pointerliu:fix-gen-inside

Conversation

@pointerliu
Copy link
Copy Markdown
Contributor

Fix #122

Changes

  • Added constant_inside_expression as a new variant of constant_expression.
  • Test case was already present in sv-parser-parser/src/tests.rs at line 5067.

Fixes failure to parse 'if (x inside {...})' at module level.
The if_generate_construct parser uses constant_expression for the
condition, but constant_expression did not include inside_expression
as a valid alternative.

Changes:
- Add Inside variant to ConstantExpression enum
- Add ConstantInsideExpression struct with (ConstantExpression, Keyword, Brace<OpenRangeList>)
- Add constant_inside_expression parser function
- Add constant_inside_expression to constant_expression alternatives

All 68 tests pass after this change.
…struct

This test was added to demonstrate the bug where 'if (x inside {...})'
at module level failed to parse. The test now passes after the fix.
@dalance
Copy link
Copy Markdown
Owner

dalance commented Mar 30, 2026

Thank you for your contribution!
I'll merge this PR.

@dalance dalance merged commit 323589c into dalance:master Mar 30, 2026
1 check passed
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.

Fail to parse inside expression in module-level if generate construct

2 participants