Repository navigation
pattern: don't let Not leak bindings of a failed match - #1855
Open
javabetatester wants to merge 1 commit into
Open
javabetatester wants to merge 1 commit into
javabetatester wants to merge 1 commit into
Conversation
Not matched its operand without a binding scope, so variables bound
by a partial match that then failed stayed in the matcher's state.
A later use of the same variable was compared with that stale value:
(BinaryExpr (Not (BinaryExpr x "+" _)) "*" x)
did not match (a*b)*c, because x stayed bound to a.
Run the operand in its own scope and drop it, as Or does for an
alternative that fails. No check uses a binding inside Not today, so
no diagnostic changes.
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.
Notmatches its operand without a binding scope, so variables bound by a partial match that then fails stay in the matcher's state. A later use of the same variable is compared with that stale value.does not match
(a*b)*c: the inner pattern bindsxtoa, fails on the operator, and the outerxis then compared withainstead of binding toc.The operand now runs in its own scope, which is dropped afterwards, as
Ordoes for an alternative that fails.No check uses a binding inside
Nottoday (ST1017 is the only user and binds nothing there), so no diagnostic changes; this only removes a trap for future patterns.TestNotDoesNotBindfails without the change.