Ruby: Fix isLocalSourceNode implementation#9022
Merged
Merged
Conversation
The old code was equivalent with the code below, which seems wrong ``` not n instanceof ExprNode or n instanceof ExprNode and localFlowStepTypeTracker+(..., n) ``` From running on real DB I found that this meant that the following node types were also included as local source nodes: - `TReturningNode` - `TSynthReturnNode` - `TSummaryNode` - `TSsaDefinitionNode` My understanding is that the first 3 should not be included. I would guess that SsaDefinitionNode should indeed be included as a LocalSourceNode, but I'm not 100% sure, so I'll see what the test results say before making further changes.
Since this is not using inline-expectation-tests, I'm not entirely sure whether these changes are OK or not, so hope to get someone else to signoff on that.
hvitved
reviewed
May 4, 2022
| n instanceof SynthReturnNode | ||
| or | ||
| // Expressions that can't be reached from another entry definition or expression. | ||
| n instanceof ExprNode and |
Contributor
There was a problem hiding this comment.
What happens if you instead remove this constraint, and the disjunct n instanceof SynthReturnNode?
Member
Author
There was a problem hiding this comment.
That seemed to do the trick 👌
The need for `SynthReturnNode` goes away if we don't restrict the nodes that can't be reached from another entry definition or expression to be `ExprNode`s
hvitved
reviewed
May 11, 2022
| | type_tracker.rb:12:1:16:3 | self in m | type tracker with call steps | type_tracker.rb:12:1:16:3 | self (m) | | ||
| | type_tracker.rb:12:1:16:3 | self in m | type tracker without call steps | type_tracker.rb:12:1:16:3 | self in m | | ||
| | type_tracker.rb:13:5:13:7 | var | type tracker without call steps | type_tracker.rb:13:5:13:7 | var | | ||
| | type_tracker.rb:13:5:13:23 | ... = ... | type tracker with call steps | type_tracker.rb:2:5:5:7 | self (field=) | |
Contributor
There was a problem hiding this comment.
For reference: The reason that ... - ... is (correctly) no longer a LocalSourceNode is because it represents the SsaDefinitionNode for the assignment, not the ExprNode.
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.
The old code was equivalent with the code below, which seems wrong
From running on real DB I found that this meant that the following node
types were also included as local source nodes:
TReturningNodeTSynthReturnNodeTSummaryNodeTSsaDefinitionNodeIt turned out that
TSynthReturnNodewas required for sure (but I don't fully undestand why), while the others don't immediately seems to be.@hvitved I've requested a review from you, since you seem to have been touching this code last. If you think it looks good, once we have filled out proper documentation for the TODO I left in the code, we can take it out of draft 👍