Avoid pointing out return
span if it has nothing to do with type error
#100130
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.
This code:
Emits this:
Specifically, that note has nothing to do with the type error in question. This is because the change implemented in #84244 tries to point out the
return
span on any type coercion error within a closure that happens after areturn
statement, regardless of if the error has anything to do with it.This is really easy to trigger -- just needs a closure (or an
async
) and an early return (or any other form, e.g.?
operator suffices) -- and super distracting in production codebases. I'm letting #84128 regress because that issue is much harder to fix correctly, and I can re-open that issue after this lands.As a drive-by, I added a
resolve_vars_if_possible
to the coercion error logic, which leads to some error improvements. Unrelated to the issue above, though.