Skip to content
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

Draft
wants to merge 8 commits into
base: 1.11.x
Choose a base branch
from
Draft

Conversation

staabm
Copy link
Contributor

@staabm staabm commented Aug 9, 2024

Comment on lines +397 to +403
$keepSeparate = true;
foreach ($this->valueTypes as $valueType) {
if ($valueType->isConstantValue()->yes()) {
$keepSeparate = false;
break;
}
}
Copy link
Contributor Author

@staabm staabm Aug 9, 2024

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

Copy link
Member

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.

Copy link
Contributor Author

@staabm staabm Aug 12, 2024

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}

Comment on lines +29 to +30
// should be array{0: mixed, 1: string|null}
assertType('array{mixed, mixed}', $row);
Copy link
Contributor Author

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed via #3309

Comment on lines +397 to +403
$keepSeparate = true;
foreach ($this->valueTypes as $valueType) {
if ($valueType->isConstantValue()->yes()) {
$keepSeparate = false;
break;
}
}
Copy link
Member

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.

@mvorisek
Copy link
Contributor

Can this PR be finished please, many of our CI pipelines are still failing because of this. Thank you in advance!

@staabm
Copy link
Contributor Author

staabm commented Aug 20, 2024

@mvorisek will continue after vacation. Please make sure to sponsor my efforts. Thanks in advance

@ondrejmirtes
Copy link
Member

@staabm FYI my patience with @mvorisek has run out and I blocked him for 1 week.

@mvorisek
Copy link
Contributor

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants