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

ArgumentTypeCoercion with multiple conditional expressions in match #9633

Closed
tuqqu opened this issue Apr 10, 2023 · 1 comment · Fixed by #9647
Closed

ArgumentTypeCoercion with multiple conditional expressions in match #9633

tuqqu opened this issue Apr 10, 2023 · 1 comment · Fixed by #9647

Comments

@tuqqu
Copy link
Contributor

tuqqu commented Apr 10, 2023

Should be no error here:

https://psalm.dev/r/e6cd62e225

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/e6cd62e225
<?php

interface Foo {}
class X implements Foo {}
class Y implements Foo {}

function accept_x_or_y(X|Y $_): int {
    return 1;
}

function test(Foo $foo): void {
    print match (true) {
        $foo instanceof X,
        $foo instanceof Y => accept_x_or_y($foo),
        default => 2,
	};
}

test(new X);
test(new Y);
Psalm output (using commit 2aaa577):

ERROR: ArgumentTypeCoercion - 14:44 - Argument 1 of accept_x_or_y expects X|Y, but parent type Foo provided

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant