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 spaceship operator for large constant unions #2886

Merged

Conversation

schlndh
Copy link
Contributor

@schlndh schlndh commented Jan 21, 2024

This PR fixes a false positive encountered by #2885 . I simplified it to smaller example: https://phpstan.org/r/892eed14-49b8-4a98-b591-90cf5741a99e

This scenario only happens with bleeding edge enabled. Without it the constant union doesn't make it into getSpaceshipType due to

if (!BleedingEdgeToggle::isBleedingEdge() && $this->shouldGeneralizeInferredType()) {

As far as I can tell, the spaceship operator should always return -1, 0, or 1: https://3v4l.org/FVeq7

@ondrejmirtes ondrejmirtes merged commit b60d12c into phpstan:1.10.x Jan 21, 2024
427 of 429 checks passed
@ondrejmirtes
Copy link
Member

Thank you!

@schlndh schlndh deleted the fix-spaceshipTypeForLargeConstantUnions branch January 21, 2024 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants