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

Int range not updated when in loop #8020

Closed
AndrolGenhald opened this issue May 26, 2022 · 2 comments · Fixed by #8934
Closed

Int range not updated when in loop #8020

AndrolGenhald opened this issue May 26, 2022 · 2 comments · Fixed by #8934

Comments

@AndrolGenhald
Copy link
Collaborator

https://psalm.dev/r/65c57ad265

I figured this would work since the variable is redefined on each loop iteration.

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/65c57ad265
<?php

/** @var int<0, max> */
$int = 0;
if ($int < 1) {
    throw new \Exception();
}
/** @psalm-trace $int */;

for ($i = 0; $i < 10; ++$i) {
    /** @var int<0, max> */
    $int = 0;
    if ($int < 1) {
        throw new \Exception();
    }
    /** @psalm-trace $int */; // Should be int<1, max>
}
Psalm output (using commit b46fb14):

INFO: Trace - 8:25 - $int: int<1, max>

INFO: Trace - 16:29 - $int: int<0, max>

@orklah
Copy link
Collaborator

orklah commented May 27, 2022

This is kinda expected. I gave up trying to change value of int ranges inside loops for a few different reasons that are still out of my skill

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

Successfully merging a pull request may close this issue.

2 participants