Conversation
This was referenced Mar 31, 2026
Collaborator
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
5 tasks
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).
…stead of panicking Fixes #9799
6ef9148 to
968be14
Compare
fca4f70 to
8dd8779
Compare
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
Replace unreachable panic with proper error reporting when user-defined extern const functions are used in constant expressions.
Type of change
Please check one:
Why is this change needed?
The code previously used
unreachable!()when encountering user-defined extern const functions in constant expressions, which would cause the compiler to panic. This is incorrect behavior as user-defined extern functions should be handled gracefully with a proper diagnostic error rather than crashing the compiler.What was the behavior or documentation before?
When a user-defined extern const function was used in a constant expression, the compiler would panic with an "Unexpected extern function in constant lowering" message.
What is the behavior or documentation after?
The compiler now properly reports error E2127 "This expression is not supported as constant" when encountering user-defined extern const functions in constant expressions, providing a clear diagnostic message to the user instead of crashing.
Related issue or discussion (if any)
Fixes #9799
Additional context
The fix includes a test case that verifies the proper error reporting behavior when
extern const fn f() -> felt252 nopanic;is called within a constant declaration.Note
Low Risk
Small, localized change to const-eval error handling plus a regression test; main risk is only altered diagnostics/behavior for previously panicking edge cases.
Overview
Fixes a compiler panic during constant evaluation: when a constant expression calls a user-defined
extern const fnthat isn’t one of the corelib-supported const-eval externs, the evaluator now returnsUnsupportedConstant(E2127) instead of hitting anunreachable!()and crashing.Adds a regression test covering
extern const fn f() -> felt252used in aconstinitializer, asserting the new diagnostic output.Written by Cursor Bugbot for commit 968be14. This will update automatically on new commits. Configure here.