Skip to content

Generalize mixed int and float constants to int|float instead of an error - #6962

Merged
ondrejmirtes merged 1 commit into
2.3.xfrom
generalize-mixed-int-float
Nov 5, 2026
Merged

ondrejmirtes merged 1 commit into
2.3.xfrom
generalize-mixed-int-float

Conversation

@ondrejmirtes

Copy link
Copy Markdown
Member

When an arithmetic or bitwise operation has more constant pairs than CALCULATE_SCALARS_LIMIT, ValueSet::generalize() widens each operand. It only handled number sets that were all integers or all floats, so a set like 0|0.01|…|0.11 fell through to createInvalid() and the operation resulted in *ERROR* (plus binaryOp.invalid). It now generalizes to int, float or int|float depending on what the set holds. The turbo ValueSet.cpp mirror gets the same change.

Closes phpstan/phpstan#15670

@ondrejmirtes
ondrejmirtes merged commit 4efc3a6 into 2.3.x Nov 5, 2026
537 of 538 checks passed
@ondrejmirtes
ondrejmirtes deleted the generalize-mixed-int-float branch November 5, 2026 21:43
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.

Binary arithmetic on a mixed int/float constant union over CALCULATE_SCALARS_LIMIT results in *ERROR*

1 participant