Skip to content

Commit 8d4bdd6

Browse files
committed
Combining a array value empty list with a non-empty list was returning a non-empty-list
1 parent 147505c commit 8d4bdd6

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/Psalm/Internal/Type/TypeCombiner.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -1358,9 +1358,7 @@ private static function handleKeyedArrayEntries(
13581358
}
13591359

13601360
if (!$combination->array_type_params || $combination->array_type_params[1]->isNever()) {
1361-
if (!$overwrite_empty_array
1362-
&& $combination->array_type_params
1363-
) {
1361+
if ($combination->array_type_params) {
13641362
foreach ($combination->objectlike_entries as &$objectlike_entry) {
13651363
$objectlike_entry = $objectlike_entry->setPossiblyUndefined(true);
13661364
}

tests/ArrayAssignmentTest.php

+9
Original file line numberDiff line numberDiff line change
@@ -2048,6 +2048,15 @@ function getQueryParams(): array
20482048
return $queryParams;
20492049
}',
20502050
],
2051+
'AssignListToNonEmptyList' => [
2052+
'code' => '<?php
2053+
/** @var array<int, non-empty-list<string>> $l*/
2054+
$l = [];
2055+
$l[] = [];',
2056+
'assertions' => [
2057+
'$l===' => 'non-empty-array<int, list<string>>',
2058+
],
2059+
],
20512060
];
20522061
}
20532062

0 commit comments

Comments
 (0)