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

"Failed to infer case value" when enum case references another enum #10560

Closed
aurimasrim opened this issue Jan 16, 2024 · 1 comment · Fixed by #10655
Closed

"Failed to infer case value" when enum case references another enum #10560

aurimasrim opened this issue Jan 16, 2024 · 1 comment · Fixed by #10655

Comments

@aurimasrim
Copy link

Hi,
I've encountered an issue where I get "Failed to infer case value" when a case of an enum references the value of another enum's case.

enum SomeEnum: string
{
    case SOME_VALUE = 'SOME_VALUE';
}

enum AnotherEnum: string
{
    case ANOTHER_VALUE = SomeEnum::SOME_VALUE->value;
}

https://psalm.dev/r/d4e839fc63

Copy link

I found these snippets:

https://psalm.dev/r/d4e839fc63
<?php declare(strict_types=1);

enum SomeEnum: string
{
    case SOME_VALUE = 'SOME_VALUE';
}

enum AnotherEnum: string
{
    case ANOTHER_VALUE = SomeEnum::SOME_VALUE->value;
}
Psalm encountered an internal error:

/vendor/vimeo/psalm/src/Psalm/Internal/PhpVisitor/Reflector/ClassLikeNodeScanner.php: Failed to infer case value for ANOTHER_VALUE

weirdan added a commit to weirdan/psalm that referenced this issue Feb 5, 2024
Resolves a number of long-standing bugs ('Failed to infer case value ...')

Fixes vimeo#10374
Fixes vimeo#10560
Fixes vimeo#10643
Fixes vimeo#8978
weirdan added a commit to weirdan/psalm that referenced this issue Feb 5, 2024
Resolves a number of long-standing bugs ('Failed to infer case value ...')

Fixes vimeo#10374
Fixes vimeo#10560
Fixes vimeo#10643
Fixes vimeo#8978
@weirdan weirdan closed this as completed in 52eadab Feb 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants