fix: return None for macro rule with missing param kind instead of panicking#9809
Open
orizi wants to merge 1 commit intoorizi/03-31-fix_missing_return_type_in_loop_bodyfrom
Conversation
5 tasks
5 tasks
Collaborator
Author
This was referenced Mar 31, 2026
eytan-starkware
approved these changes
Mar 31, 2026
Contributor
eytan-starkware
left a comment
There was a problem hiding this comment.
@eytan-starkware reviewed 2 files and all commit messages, and made 1 comment.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on TomerStarkware).
TomerStarkware
approved these changes
Apr 1, 2026
Collaborator
TomerStarkware
left a comment
There was a problem hiding this comment.
@TomerStarkware made 1 comment.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on orizi).
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.

Summary
Fixed handling of declarative macro parameters that are missing kind specifiers by returning
Noneinstead of panicking withunreachable!(), and added a test case to verify proper error reporting for this scenario.Type of change
Please check one:
Why is this change needed?
The code was using
unreachable!()for a case that can actually occur when macro parameters are missing kind specifiers, causing the compiler to panic instead of gracefully handling the error and providing proper diagnostics to the user.What was the behavior or documentation before?
When a declarative macro parameter was missing a kind specifier (e.g.,
($x)instead of($x:expr)), the compiler would panic with an "unreachable" error during macro rule matching.What is the behavior or documentation after?
The compiler now gracefully handles missing kind specifiers by returning
Nonefrom the matching function, allowing proper error diagnostics to be generated (E1010: "Macro parameter must have a kind" and E2158: "No matching rule found in inline macro").Related issue or discussion (if any)
Fixes #9797
Additional context
The test case demonstrates that the compiler now properly reports two errors: one for the missing kind specifier in the macro definition, and another for the failed macro invocation due to no matching rules.
Note
Low Risk
Low risk: small, localized change to macro pattern matching error handling plus a regression test; behavior only changes for invalid macro definitions.
Overview
Prevents a compiler panic during declarative macro matching when a macro rule parameter has no kind specifier (e.g.,
($x)), by treating that rule as a non-match (None) rather than hittingunreachable!().Adds a semantic test case asserting the expected diagnostics for this invalid macro definition, including the missing-kind error and the subsequent "no matching rule" error at the call site.
Written by Cursor Bugbot for commit dbb21ea. This will update automatically on new commits. Configure here.