Skip to content

Conversation

@staabm
Copy link
Contributor

@staabm staabm commented Sep 12, 2021

@staabm staabm marked this pull request as ready for review September 12, 2021 08:57
@clxmstaab clxmstaab force-pushed the unary-minus-int-range branch from 9e3851f to 159fd4f Compare September 12, 2021 09:29
@staabm
Copy link
Contributor Author

staabm commented Sep 12, 2021

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)) {
Copy link
Contributor Author

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?

Copy link
Member

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.

Copy link
Contributor Author

@staabm staabm Sep 12, 2021

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> ?

Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fix in #670

Copy link
Contributor Author

@staabm staabm Sep 13, 2021

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

@staabm
Copy link
Contributor Author

staabm commented Sep 12, 2021

@ondrejmirtes we can merge here as is. The multiplication bug will be fixed separately

@ondrejmirtes ondrejmirtes merged commit 33af274 into phpstan:master Sep 12, 2021
@ondrejmirtes
Copy link
Member

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.

4 participants