Conversation
…local use alias
`specialize_generic_statement_arg` unwrapped the `Maybe` returned by
`specialize_generic_module_item`, which errors on e.g. `TooManyGenericArguments`.
Every sibling resolution path propagates that error with `?`; only the
statement-`use` path (`ResolvedBase::StatementEnvironment`) unwrapped, so
`use Pair as P; P::<felt252, u8, u16> { .. }` panicked instead of emitting E2163.
Return `Maybe` and propagate with `?`.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
PR SummaryLow Risk Overview
A diagnostic regression test expects Reviewed by Cursor Bugbot for commit 53098f7. 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 2 files and all commit messages, and made 1 comment.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on eytan-starkware).

Summary
Propagates errors from
specialize_generic_module_iteminspecialize_generic_inner_itemby changing the return type fromResolvedConcreteItemtoMaybe<ResolvedConcreteItem>and using?instead of.unwrap(). Call sites are updated to propagate the error with?. A regression test is added covering the case where a localusealias is instantiated with the wrong number of generic arguments (e.g.,use Pair as P; P::<felt252, u8, u16> { ... }).Type of change
Please check one:
Why is this change needed?
When a local
usealias was instantiated with the wrong number of generic arguments,specialize_generic_module_itemreturned anErr, but the call inspecialize_generic_inner_itemcalled.unwrap()on that result, causing an ICE (internal compiler error) instead of a proper diagnostic.What was the behavior or documentation before?
Providing the wrong number of generic arguments to a type accessed through a local
usealias (e.g.,use Pair as P; P::<felt252, u8, u16> { ... }) triggered an ICE rather than emitting a diagnostic error.What is the behavior or documentation after?
The compiler now correctly emits a diagnostic error (
E2163: Expected 2 generic arguments, found 3.) and no longer panics in this case.Related issue or discussion (if any)
N/A
Additional context
The fix is minimal: replacing
.unwrap()with?and adjusting the return type ofspecialize_generic_inner_itemaccordingly.