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 ReservedWord issue #10905

Open
ghostwriter opened this issue Apr 12, 2024 · 3 comments
Open

False-positive ReservedWord issue #10905

ghostwriter opened this issue Apr 12, 2024 · 3 comments

Comments

@ghostwriter
Copy link

https://psalm.dev/r/3c8525e655

https://psalm.dev/r/9d2811b8b0

Copy link

I found these snippets:

https://psalm.dev/r/3c8525e655
<?php

declare(strict_types=1);

namespace Tests\Fixture;

final class Test {}
final class Test2 {}

final class IntersectionParameter
{
    public function __invoke(
        Test&Test2 $test
    ): void {
        unset($test);
    }
}
Psalm output (using commit 08afc45):

ERROR: ReservedWord - 13:9 - Parameter cannot be never
https://psalm.dev/r/9d2811b8b0
<?php

declare(strict_types=1);

namespace Tests\Fixture;

final class Test {}

final class Test2 {}

final class IntersectionParameter
{
    public function __invoke(
        Test&Test2 $test
    ): void {
        unset($test);
    }
}

(new IntersectionParameter())(new Test);
Psalm output (using commit 08afc45):

ERROR: InvalidArgument - 20:31 - Argument 1 of Tests\Fixture\IntersectionParameter::__invoke expects never, but Tests\Fixture\Test provided

ERROR: ReservedWord - 14:9 - Parameter cannot be never

@orklah
Copy link
Collaborator

orklah commented Apr 12, 2024

How can your parameter be both a Test1 and a Test2 when they don't share a parent?

@weirdan
Copy link
Collaborator

weirdan commented Apr 12, 2024

Psalm shouldn't report the ResevedWord here though

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

3 participants