Fix spurious error when assigning to a field on an as cast in a try block#5070
Open
SeanTAllen wants to merge 1 commit intomainfrom
Open
Fix spurious error when assigning to a field on an as cast in a try block#5070SeanTAllen wants to merge 1 commit intomainfrom
as cast in a try block#5070SeanTAllen wants to merge 1 commit intomainfrom
Conversation
… block The `as` operator desugars to a match with a consume of an internal hygienic variable. The refer pass's `ast_get_child` function searched the entire assignment LHS subtree — including the desugared match's scope — for consumed variable names, producing a false positive that triggered the verify pass error. Stopping the search at scope boundaries prevents descending into match-internal variables that aren't assignment targets. Closes #3604
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.
Assigning to a field on the result of an
asexpression inside atryblock produced a spurious error about consumed identifiers. Theasoperator desugars to a match with aconsumeof an internal hygienic variable, and the refer pass'sast_get_childfunction searched the entire assignment LHS subtree — including the desugared match's scope — for consumed variable names. This produced a false positive that triggered the verify pass error.The fix stops
ast_get_childfrom recursing into children that introduce their own scope. Variables bound in those scopes (like the match-internal hygienic variable) aren't assignment targets of the outer expression.Closes #3604