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

False positive on int values: Comparison operation ">" between int<min, 6> and 10 is always false #5656

Closed
muxx opened this issue Sep 20, 2021 · 9 comments
Labels

Comments

@muxx
Copy link

muxx commented Sep 20, 2021

Bug report

This is logic of validation OKPO number of companies in Russia.

Here example where you can see than $i can be greater 10 and logic is correct http://sandbox.onlinephpfunctions.com/code/afa48ae0eed6e2bc2407cd23984dbee39a962098

Code snippet that reproduces the problem

https://phpstan.org/r/10a2ec68-73ad-4c97-90eb-a792e86e0872

Expected output

Don't show error

Did PHPStan help you today? Did it make you happy in any way?

Yes, of course!)

@ondrejmirtes
Copy link
Member

Hi, it'd help me if you debugged where PHPStan starts to get things wrong with the dumpType function like this: https://phpstan.org/r/06688a41-533c-43f2-986b-b44e42f6c828

@phpstan-bot
Copy link
Contributor

@muxx After the latest commit in dev-master, PHPStan now reports different result with your code snippet:

@@ @@
-17: Comparison operation ">" between int<min, 6> and 10 is always false.
+ 3: Function okpoValidate() should return bool but return statement is missing.
Full report
Line Error
3 Function okpoValidate() should return bool but return statement is missing.

@phpstan-bot
Copy link
Contributor

@ondrejmirtes After the latest commit in dev-master, PHPStan now reports different result with your code snippet:

@@ @@
-15: Dumped type: int<min, 3>
-18: Comparison operation ">" between int<min, 6> and 10 is always false.
-23: Dumped type: int<min, 7>
-27: Dumped type: int<min, 7>
-33: Dumped type: int<min, 7>
+ 3: Function okpoValidate() should return bool but return statement is missing.
Full report
Line Error
3 Function okpoValidate() should return bool but return statement is missing.

@muxx
Copy link
Author

muxx commented Dec 6, 2021

In version 1.* all ok!

@muxx muxx closed this as completed Dec 6, 2021
@ondrejmirtes ondrejmirtes reopened this Dec 6, 2021
@phpstan-bot
Copy link
Contributor

@muxx After the latest commit in dev-master, PHPStan now reports different result with your code snippet:

@@ @@
-17: Comparison operation ">" between int<min, 6> and 10 is always false.
+17: Comparison operation ">" between int<1, 6> and 10 is always false.
Full report
Line Error
17 Comparison operation ">" between int<1, 6> and 10 is always false.

@phpstan-bot
Copy link
Contributor

@ondrejmirtes After the latest commit in dev-master, PHPStan now reports different result with your code snippet:

@@ @@
-15: Dumped type: int<min, 3>
-18: Comparison operation ">" between int<min, 6> and 10 is always false.
-23: Dumped type: int<min, 7>
-27: Dumped type: int<min, 7>
-33: Dumped type: int<min, 7>
+15: Dumped type: int<1, 3>
+18: Comparison operation ">" between int<1, 6> and 10 is always false.
+23: Dumped type: int<2, 7>
+27: Dumped type: int<1, 7>
+33: Dumped type: int<1, 7>
Full report
Line Error
15 Dumped type: int<1, 3>
18 Comparison operation ">" between int<1, 6> and 10 is always false.
23 Dumped type: int<2, 7>
27 Dumped type: int<1, 7>
33 Dumped type: int<1, 7>

@phpstan-bot
Copy link
Contributor

@muxx After the latest commit in dev-master, PHPStan now reports different result with your code snippet:

@@ @@
-17: Comparison operation ">" between int<min, 6> and 10 is always false.
+No errors

@phpstan-bot
Copy link
Contributor

@ondrejmirtes After the latest commit in dev-master, PHPStan now reports different result with your code snippet:

@@ @@
-15: Dumped type: int<min, 3>
-18: Comparison operation ">" between int<min, 6> and 10 is always false.
-23: Dumped type: int<min, 7>
-27: Dumped type: int<min, 7>
-33: Dumped type: int<min, 7>
+15: Dumped type: 1|3
+23: Dumped type: int<2, 11>
+27: Dumped type: int<1, 11>
+33: Dumped type: int<1, 11>
Full report
Line Error
15 `Dumped type: 1
23 Dumped type: int<2, 11>
27 Dumped type: int<1, 11>
33 Dumped type: int<1, 11>

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants