-
Notifications
You must be signed in to change notification settings - Fork 428
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
support unary-minus on IntegerRangeType #669
Conversation
9e3851f
to
159fd4f
Compare
failling test is unrelated. just rebased. |
if ($type instanceof IntegerRangeType) { | ||
$negativeRange = $this->resolveType(new Node\Expr\BinaryOp\Mul($node->expr, new LNumber(-1))); | ||
|
||
if ( $negativeRange instanceof IntegerRangeType && ($negativeRange->getMin() === null || $negativeRange->getMax() === null)) { |
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.
Actually I was not sure whether multiplication by -1 should have already returned the range as we need it and this if-case actually compensates a bug in the Mul logic?
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 don't know, you tell me :) Feel free to fix more bugs here.
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.
Do we expect -$b === $b * -1
Given $b = int<min, 5>
?
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.
Seems like it. Here's a small script I made to generate equations for Wolfram: https://3v4l.org/AUHH7
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.
Fix in #670
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.
btw: the same is true for division: Wolfram
@ondrejmirtes we can merge here as is. The multiplication bug will be fixed separately |
Thank you! |
refs phpstan/phpstan#5614