-
Notifications
You must be signed in to change notification settings - Fork 547
Fix MutatingScope->compareVariableTypeHolders() #4641
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
Conversation
|
This pull request has been marked as ready for review. |
src/Analyser/MutatingScope.php
Outdated
| unset($otherVariableTypeHolders[$variableExprString]); | ||
| } | ||
|
|
||
| if (count($otherVariableTypeHolders) > 0) { |
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.
in the loop this array is reduced one offset at a time, which only makes sense if we check afterwards whether $otherVariableTypeHolders contained elements which were not contained in $variableTypeHolders
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.
Can you write a failing test against this? Or is it just about performance?
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.
yeah, I think I need to come up with a test. looks like a bug to me.
not perf related, just stumbled over it, while looking into #4640 (comment)
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.
Can you write a failing test against this? Or is it just about performance?
I looked into it and tried. I think a case where $other has more types/conditions than $this cannot happen, because in all cases where we call MutatingScope->equals() we do it like $bodyScope->equals($prevScope), meaning we compare a generalized scope (one with reduced information) with one with more information.
this means the scope we get as parameter will always have less information than $this so the theoretical case this PR tried to fix can never happen. but this also means there is dead code in the method, which I now have deleted.
src/Analyser/MutatingScope.php
Outdated
| unset($otherVariableTypeHolders[$variableExprString]); | ||
| } | ||
|
|
||
| if (count($otherVariableTypeHolders) > 0) { |
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.
Can you write a failing test against this? Or is it just about performance?
|
Thank you! |
No description provided.