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
Wrong type inference #4326
Labels
Comments
I found these snippets: https://psalm.dev/r/422d9413c9<?php
/**
* @template E
* @template F
*/
final class Either
{}
/**
* @template S
* @template T
* @template A
* @template B
*/
final class Prism
{
/** @var callable(B): T */
private $review;
/** @var callable(S): Either<T, A> */
private $preview;
/**
* @template C
* @template D
* @param Prism<A, B, C, D> $that
*/
public function compose(Prism $that): void
{
/** @psalm-trace $preview */
$preview = $that->preview;
}
}
|
Reduced to https://psalm.dev/r/565bb30e0b |
I found these snippets: https://psalm.dev/r/565bb30e0b<?php
/**
* @template A
* @template B
*/
final class Foo
{
/** @var Traversable<A, B> */
public $traversable;
/**
* @param Foo<B, A> $flipped
* @return Traversable<B, A>
*/
public function getFlippedTraversable(Foo $flipped): Traversable
{
return $flipped->traversable;
}
}
|
Ah, I just fixed it for methods |
that was fast, thank you! |
muglug
added a commit
that referenced
this issue
Oct 19, 2020
danog
pushed a commit
to danog/psalm
that referenced
this issue
Jan 29, 2021
danog
pushed a commit
to danog/psalm
that referenced
this issue
Jan 29, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Consider this snippet of code (see https://psalm.dev/r/422d9413c9)
Psalm says that the type of
$preview
iscallable(C): Either<D, C>
, while I'm expecting it to becallable(A): Either<B, C>
.Am I doing something wrong or is Psalm inferring the wrong type here?
The text was updated successfully, but these errors were encountered: