-
Notifications
You must be signed in to change notification settings - Fork 446
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
Fix bug in array-shape subtraction #3308
base: 1.11.x
Are you sure you want to change the base?
Conversation
$keepSeparate = true; | ||
foreach ($this->valueTypes as $valueType) { | ||
if ($valueType->isConstantValue()->yes()) { | ||
$keepSeparate = false; | ||
break; | ||
} | ||
} |
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.
we somehow need to identify which constant arrays we can/want to keep separte (in our case tagged unions), without running into "is always false" comparison false positives like
list<array{string, 1|2|3|4|5|6|7}> and list<array{string, 1|2|3|4|5|6|7, int}> will always evaluate to false
I think my approach is wrong, but I have no better idea atm
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.
Any change to isSuperTypeOf logic needs tests in TypeCombinatorTest::dataUnion and dataIntersect. So please express there what you're trying to achieve, only when reviewing that I can decide if it makes sense or not.
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.
I could not figure out a dataUnion and dataIntersect test.
but what made sense to me was a test like
subtract array{mixed}
from array{mixed, string|null, mixed}|array{mixed}
should lead to array{mixed, string|null, mixed}
// should be array{0: mixed, 1: string|null} | ||
assertType('array{mixed, mixed}', $row); |
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.
I think thats another bug
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.
fixed via #3309
$keepSeparate = true; | ||
foreach ($this->valueTypes as $valueType) { | ||
if ($valueType->isConstantValue()->yes()) { | ||
$keepSeparate = false; | ||
break; | ||
} | ||
} |
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.
Any change to isSuperTypeOf logic needs tests in TypeCombinatorTest::dataUnion and dataIntersect. So please express there what you're trying to achieve, only when reviewing that I can decide if it makes sense or not.
Can this PR be finished please, many of our CI pipelines are still failing because of this. Thank you in advance! |
@mvorisek will continue after vacation. Please make sure to sponsor my efforts. Thanks in advance |
@ondrejmirtes, Ondřej, I do not want you to talk to me like this. If some of my communication ruin your patience, please always share the reasons with me to be able to understand your attitude better. I hope we can talk about these feelings openly. Thank you. |
closes phpstan/phpstan#11488