From 6044cc702c4d8d7ab5e6e904c89c8ad5b4665391 Mon Sep 17 00:00:00 2001 From: RobChett Date: Sun, 14 May 2023 12:27:47 +0100 Subject: [PATCH] Combining a array value empty list with a non-empty list was returning a non-empty-list --- src/Psalm/Internal/Type/TypeCombiner.php | 2 +- tests/ArrayAssignmentTest.php | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Psalm/Internal/Type/TypeCombiner.php b/src/Psalm/Internal/Type/TypeCombiner.php index 7bad56440..67850a284 100644 --- a/src/Psalm/Internal/Type/TypeCombiner.php +++ b/src/Psalm/Internal/Type/TypeCombiner.php @@ -1516,7 +1516,7 @@ final class TypeCombiner $generic_type_params[1], $objectlike_generic_type, $codebase, - $overwrite_empty_array, + false, $allow_mixed_union, ); } diff --git a/tests/ArrayAssignmentTest.php b/tests/ArrayAssignmentTest.php index 91a319f2f..d7651949d 100644 --- a/tests/ArrayAssignmentTest.php +++ b/tests/ArrayAssignmentTest.php @@ -2048,6 +2048,15 @@ class ArrayAssignmentTest extends TestCase return $queryParams; }', ], + 'AssignListToNonEmptyList' => [ + 'code' => '> $l*/ + $l = []; + $l[] = [];', + 'assertions' => [ + '$l===' => 'non-empty-array>', + ], + ], ]; }