-
Notifications
You must be signed in to change notification settings - Fork 668
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
No error when adding list to array of non-empty-list #9594
Labels
Comments
I found these snippets: https://psalm.dev/r/7ddbfc99b9<?php
class A {
/**
* @psalm-var array<int, non-empty-list<string>>
*/
private array $l = [];
/** @psalm-param list<string> $v */
public function addResult(array $v): void {
$this->l[] = $v;
/** @psalm-trace $v $this->l */
}
}
|
Simpler case and proof that type info is lost in both directions |
I found these snippets: https://psalm.dev/r/e97c284178<?php
/** @var array<int, array<never, never>> $a*/
$a = [[]];
$a[] = ['A'];
// $a should be non-empty-array<int, list<string>>
/** @var array<int, non-empty-list<string>> $b*/
$b = [['A']];
$b[] = [];
// $b should be non-empty-array<int, list<string>>
/** @psalm-trace $a $b */
return [$a, $b];
|
Fixed in #9787 (I assume) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There should be a warning when adding a list to an array of non-empty-lists
https://psalm.dev/r/7ddbfc99b9
The text was updated successfully, but these errors were encountered: