-
Notifications
You must be signed in to change notification settings - Fork 659
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 UnusedVariable when wrapping catched exception #6659
Labels
Comments
I found these snippets: https://psalm.dev/r/24f4faa0bd<?php
function test(): void
{
try {
return;
} catch (\RuntimeException $exception) {
$exception = new \LogicException('test', 0, $exception);
} catch (Throwable $exception) {
$exception = new \InvalidArgumentException('test 2', 0, $exception);
}
echo $exception->getMessage();
}
https://psalm.dev/r/9b5d2bd80c<?php
function test(): void
{
try {
return;
} catch (\RuntimeException $exception) {
/** @psalm-suppress UnusedVariable */
$exception = new \LogicException('test', 0, $exception);
} catch (Throwable $exception) {
$exception = new \InvalidArgumentException('test 2', 0, $exception);
}
echo $exception->getMessage();
}
|
discordier
added a commit
to phpcq/phpcq
that referenced
this issue
Oct 14, 2021
As supressing on line level does not work (see vimeo/psalm#6659), we now suppress it on function level.
@AndrolGenhald do you think this is fixed too? |
Probably not, I might take a look at it tomorrow though (or at least this week, time does tend to get away from me...). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When an exception is catched and overridden in the catch block, psalm thinks the variable is unused (might be related to #5700).
https://psalm.dev/r/24f4faa0bd
To make the issue even worse, this can NOT be supressed:
https://psalm.dev/r/9b5d2bd80c
The text was updated successfully, but these errors were encountered: