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

non-empty-list conditionals regression #9945

Open
vudaltsov opened this issue Jun 21, 2023 · 3 comments
Open

non-empty-list conditionals regression #9945

vudaltsov opened this issue Jun 21, 2023 · 3 comments

Comments

@vudaltsov
Copy link
Contributor

https://psalm.dev/r/400bbb5a4a

This used to work earlier. I can figure out the exact version if needed.

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/400bbb5a4a
<?php

/**
 * @param list $items
 * @return ($items is non-empty-list ? non-empty-list : list)
 */
function test(array $items): array
{
    return array_map(
        static fn (mixed $item): mixed => $item,
        $items,
    );
}
Psalm output (using commit bb28c5a):

INFO: LessSpecificReturnStatement - 9:12 - The type 'array<array-key, mixed>' is more general than the declared return type 'list<mixed>' for test

INFO: MoreSpecificReturnType - 5:12 - The declared return type 'list<mixed>' for test is more specific than the inferred return type 'array<array-key, mixed>'

@orklah
Copy link
Collaborator

orklah commented Jun 21, 2023

May have changed in #8820

@boesing
Copy link
Contributor

boesing commented Jun 23, 2023

Most likely same issue as in #9917
TKeyedArray seems to lack not-empty functionality.

I tried this with psalm v5.8, v5.0 and 4.30 and none of these versions did actually supported this.

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

No branches or pull requests

3 participants