Conversation
PR SummaryLow Risk Overview Updates a large set of semantic, lowering, and StarkNet plugin diagnostic golden tests to match the new, more precise error locations. Reviewed by Cursor Bugbot for commit 87ddad5. Bugbot is set up for automated code reviews on this repo. Configure here. |
7ba1a92 to
d47df27
Compare
93b5567 to
bab48b5
Compare
TomerStarkware
left a comment
There was a problem hiding this comment.
@TomerStarkware reviewed 18 files and all commit messages, and made 1 comment.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on eytan-starkware).
bab48b5 to
53c78ee
Compare
d47df27 to
5c3381f
Compare
53c78ee to
5970494
Compare
5c3381f to
b9b4318
Compare
5970494 to
50c1c11
Compare
b9b4318 to
edb43d9
Compare
50c1c11 to
5de80a4
Compare
edb43d9 to
d9d755d
Compare
5de80a4 to
e14ed81
Compare
TomerStarkware
left a comment
There was a problem hiding this comment.
@TomerStarkware reviewed 3 files and all commit messages, and made 1 comment.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on eytan-starkware).
e14ed81 to
f943def
Compare
d9d755d to
12ffa14
Compare
…g expression
Replace `compute_root_expr`'s return-type conform stable_ptr (the whole
function block, or the static return-type clause) with a recursive
`value_producer_stable_ptr` that drills through block tails, match arms,
and if branches to the actual value-contributing sub-expression.
For `fn foo() { let x = 5; x }`, the error now points at `x` instead of
the whole function block. For `fn foo() { match b { true => 5, … } }`,
it points at `5` — the first non-`never` arm's value-producer.
f943def to
87ddad5
Compare

Summary
The
WrongReturnTypediagnostic now points to the actual value-producing expression instead of the return type annotation in the function signature.A new helper function
value_producer_stable_ptris introduced incompute.rsthat drills through blocks (to their tail), match expressions (to the first non-neverarm), and if expressions (to the first non-neverbranch) to locate the concrete sub-expression responsible for producing the returned value. This pointer is used as the diagnostic span instead of the return type clause in the signature.Type of change
Please check one:
Why is this change needed?
Previously, when a function returned a value of the wrong type, the error diagnostic highlighted the return type annotation in the function signature (e.g.,
-> u8). This was often unhelpful because the annotation itself is correct — the problem is the expression that actually produces the value. Pointing at the return type annotation forced developers to manually trace which expression was at fault.What was the behavior or documentation before?
The
E2042: Unexpected return typediagnostic pointed to the return type clause in the function signature, for example:What is the behavior or documentation after?
The diagnostic now points directly to the offending value-producing expression:
For compound expressions like blocks, matches, and ifs, the diagnostic drills into the relevant sub-expression rather than spanning the entire function body.
Related issue or discussion (if any)
Fixes #6486
Additional context
For empty function bodies (no tail expression), the diagnostic falls back to pointing at the closing
}of the block, which correctly indicates that a value is missing.