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

Integer comparision after decrementing a value in a do-while loop triggers error #852

Closed
mjaschen opened this issue Jun 30, 2018 · 1 comment
Labels

Comments

@mjaschen
Copy link

mjaschen commented Jun 30, 2018

The following code creates a false positive error in Psalm 1.1.4 (it worked fine up to Psalm 1.1.3):

<?php
$i = 5;
do {} while (--$i > 0);
echo $i === 0;

The condition $i === 0 evaluates of course to true after the loop finishes.

Demonstration of this issue: https://getpsalm.org/r/556d8678bc

Psalm doesn't complain when using a while-loop:

<?php
$i = 5;
while (--$i > 0) {}
echo $i === 0;

Demostration: https://getpsalm.org/r/2fed4dd9ca

@mjaschen
Copy link
Author

PR #853 provides a test case for this behaviour.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants