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
UnusedVariable false positive with thrown and caught exceptions #5700
Labels
Comments
I found these snippets: https://psalm.dev/r/95027a9b22<?php
function test(bool $b): string {
$test = 'test';
try {
if ($b) {
$test .= ' true';
throw new Exception;
}
} catch (Exception $e) {
}
return $test . "\n";
}
print test(false);
print test(true);
|
Also a different false-positive for type assignment (because unused variable tracking uses the same pathways): https://psalm.dev/r/621191710b |
I found these snippets: https://psalm.dev/r/621191710b<?php
function test(): void {
$did_throw = false;
try {
if (rand(0, 1)) {
$did_throw = true;
throw new Exception;
}
} catch (Exception $e) {
}
if ($did_throw) {}
}
|
I also ran in this issue, and the issue went away after I downgraded all the way to 4.6.4 |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If a variable is modified just before an exception is thrown, and then caught in the same context and the variable used, psalm emits an UnusedVariable issue.
https://psalm.dev/r/95027a9b22
https://3v4l.org/9UkSq
The text was updated successfully, but these errors were encountered: