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
Incorrect inferred return type 'never' #8862
Comments
I found these snippets: https://psalm.dev/r/4d5cfb806a<?php
function foo(): void
{
if (random_int(0, 1) === 1) {
throw new \Exception();
}
}
|
/cc: @kkmuffme |
I'm unable to reproduce this locally with psalm 5.1.0 - I get "No errors found!" no matter if I try with phpdoc or with : void native type. Maybe something in #8828 broke this? (unlikely, that was the last related thing modified which is why I'm asking) What version is running on psalm.dev? @weirdan |
Currently it's ef02ded - a couple of commits behind the HEAD of master. |
@jack-worman which version do you get this error on? 5.1.0? |
@kkmuffme I am on 5.1.0 |
For some reason I cannot get this error on 5.1.0 with this code. |
I still cannot reproduce this on psalm 5.2.0 Can you confirm that you still get this error on psalm 5.2.0? If you still get this error, can you try with my psalm config:
|
@kkmuffme it requires (undocumented) |
Could this setting get documented in https://psalm.dev/docs/running_psalm/configuration/ ? Anyway the bug is bc of I won't be able to fix this atm, but I guess it's a good first issue to modify it to check if function returns void implicitly. |
btw this is not specific to never, this happens with all other implicit void returns too: |
I found these snippets: https://psalm.dev/r/b0e397c14e<?php
function foo(): void
{
if (random_int(0, 1) === 1) {
return false;
}
}
https://psalm.dev/r/6ffb302b9e<?php
function foo(): void
{
if (random_int(0, 1) === 1) {
return 10;
}
}
|
It actually has the same issue with void + null when it's explicit too: https://psalm.dev/r/6f227ae9b9 |
I found these snippets: https://psalm.dev/r/6f227ae9b9<?php
function foo(): void
{
if (random_int(0, 1) === 1) {
throw new \Exception();
}
return;
}
|
* fix implicit void return type errors https://psalm.dev/r/b0e397c14e * fix void + never = null return type error https://psalm.dev/r/6f227ae9b9 * fixes vimeo#8912 and vimeo#8862
* fix implicit void return type errors https://psalm.dev/r/b0e397c14e * fix void + never = null return type error https://psalm.dev/r/6f227ae9b9 * fixes vimeo#8912 and vimeo#8862
* fix implicit void return type errors https://psalm.dev/r/b0e397c14e * fix void + never = null return type error https://psalm.dev/r/6f227ae9b9 * fixes vimeo#8912 and vimeo#8862
* fix implicit void return type errors https://psalm.dev/r/b0e397c14e * fix void + never = null return type error https://psalm.dev/r/6f227ae9b9 * fixes vimeo#8912 and vimeo#8862
https://psalm.dev/r/4d5cfb806a
void|never
is being incorrectly reduced tonever
instead ofvoid
.The text was updated successfully, but these errors were encountered: