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

@psalm-yield not working for child classes #6983

Closed
danog opened this issue Nov 24, 2021 · 1 comment
Closed

@psalm-yield not working for child classes #6983

danog opened this issue Nov 24, 2021 · 1 comment

Comments

@danog
Copy link
Collaborator

danog commented Nov 24, 2021

https://psalm.dev/r/4549ee95d8

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/4549ee95d8
<?php
/** 
 * @template T
 * @psalm-yield T
 */
class a {
}

/**
 * @template TT1
 * @template TT2
 * @extends a<TT2>
 */
class b extends a {}

function aa(): \Generator {
    /** @var a<"test2"> */
    $b = new b;
    $result = yield $b;
    /** @psalm-trace $result */
    return $result;
}
function bb(): \Generator {
    /** @var b<"test1", "test2"> */
    $b = new b;
    $result = yield $b;
    /** @psalm-trace $result */
    return $result;
}
Psalm output (using commit fdf3a8d):

INFO: Trace - 21:5 - $result: "test2"

INFO: MixedAssignment - 26:5 - Unable to determine the type that $result is being assigned to

INFO: Trace - 28:5 - $result: b<"test1", "test2">|mixed

danog added a commit to nicelocal/psalm that referenced this issue Oct 13, 2022
@danog danog closed this as completed Oct 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants