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
Psalm not inferring generator template parameters when using ternary #8564
Labels
Comments
I found these snippets: https://psalm.dev/r/35d889bd48<?php
/** @psalm-yield int */
class a {}
/**
* @return Generator<mixed, mixed, mixed, int>
*/
function a(): Generator {
return random_int(0, 1) ? 123 : yield new a;
}
/**
* @return Generator<mixed, mixed, mixed, int>
*/
function b(): Generator {
return yield new a;
}
|
danog
changed the title
Psalm not inferring generator template parameters
Psalm not inferring generator template parameters when using ternary
Oct 11, 2022
Pretty sure it should be handled here:
But this piece of code breaks my mind each time. It's a recursive method that collects every return type and yield type through each statement. So it should have a Ternary handling somewhere (possibly around the place where we handle Ifs) |
danog
added a commit
to nicelocal/psalm
that referenced
this issue
Oct 13, 2022
orklah
added a commit
that referenced
this issue
Oct 13, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://psalm.dev/r/35d889bd48
The error for the function with the ternary does not contain the actual template parameters for \Generator.
The text was updated successfully, but these errors were encountered: