-
Couldn't load subscription status.
- Fork 4.2k
Fix VariablesDeclaredWalker with recursive patterns #80910
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| { | ||
| switch (pattern) | ||
| { | ||
| case BoundRecursivePattern r: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| { | ||
| switch (pattern) | ||
| { | ||
| case BoundRecursivePattern r: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of having a helper that must know how to dive deep into patterns and rely on containing nodes to call it, can we override appropriate Refers to: src/Compilers/CSharp/Portable/FlowAnalysis/VariablesDeclaredWalker.cs:70 in e745150. [](commit_id = e745150, deletion_comment = False) |
|
Done with review pass (commit 2), tests were not looked at. |
I don't think this could be solved, for example, by only overriding Visit for the specific BoundPattern kinds, which directly contain variables. Instead you would have to declare all the Visit methods for all the pattern subtypes, and write the code to traverse the parts of the patterns which could contain variables. This is because the base type Visit methods already don't do this, to the best of my understanding. I think this approach, as well as the approach in iteration 2, would also end up requiring re-implementing "safe" traversal of binary patterns (because of the need to find variables in A few alternatives I considered:
It's possible I missed something that would make fixing this easier to accomplish. Let me know if you have any further thoughts. |
I guess it would be fine for |
Closes #79489
@CyrusNajmabadi PTAL