Fix logic errors in match-statement Array & Dictionary patterns #57151
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.
Fixes #57004
Fixes #57150
This fixes 2 logic errors about match statements.
The first is about the order of logical operations. Currently,
OR
ing with the result of the previous pattern of the same branch happens before checking the elements of the Array / Dictionary (for the respective patterns). This causes weird behavior, ranging from skipped cases (#57004) to runtime errors:The second is specific to the Dictionary Pattern. When the pattern has a key with no value supplied, it is supposed to require the existence of the key in order to successfully match. However, currently its existence only contributes to the result if there is also a value supplied. (#57150)