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

list -> iterable assertion, item type is lost #9946

Closed
zerkms opened this issue Jun 22, 2023 · 1 comment · Fixed by #9950
Closed

list -> iterable assertion, item type is lost #9946

zerkms opened this issue Jun 22, 2023 · 1 comment · Fixed by #9950

Comments

@zerkms
Copy link
Contributor

zerkms commented Jun 22, 2023

https://psalm.dev/r/13b2f5d8ad

I'm sure this worked before, the assertion is from webmozart/assert and I'm sure I've used it in similar cases million times.

Expected: list<mixed> + iterable<int> assertion should result in list<int>.

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/13b2f5d8ad
<?php

/**
  * @psalm-assert iterable<int> $value
  */
function allInteger(mixed $value): void
{}

/**
 * @param list<mixed> $a
 * @return list<int>
 */
function wat(array $a): array {
    allInteger($a);
    return $a;
}
Psalm output (using commit bb28c5a):

INFO: UnusedParam - 6:27 - Param value is never referenced in this method

INFO: MixedReturnTypeCoercion - 15:12 - The type 'list{int, ...<mixed>}' is more general than the declared return type 'list<int>' for wat

INFO: MixedReturnTypeCoercion - 11:12 - The declared return type 'list<int>' for wat is more specific than the inferred return type 'list{int, ...<mixed>}'

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