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

False positive ArgumentTypeCoercion with intersection types of closure arguments #11032

Open
blackwolf12333 opened this issue Jun 28, 2024 · 1 comment

Comments

@blackwolf12333
Copy link

I expected the below to typecheck but it errors

https://psalm.dev/r/5428c288c8

Copy link

I found these snippets:

https://psalm.dev/r/5428c288c8
<?php

class Item {}

interface HasAncestor {}

class TestItem1 extends Item implements HasAncestor {}

/**
* @param pure-Closure(HasAncestor&Item): true $fn
*/
function takesClosure(Closure $fn) : void {
    $item = new TestItem1();
    $fn($item);
}

takesClosure(fn(TestItem1 $item) => !!$item);
Psalm output (using commit 16b24bd):

ERROR: ArgumentTypeCoercion - 17:14 - Argument 1 of takesClosure expects pure-Closure(HasAncestor&Item):true, but parent type pure-Closure(TestItem1):true 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

No branches or pull requests

1 participant