From f57d37a7f7b5fb7e399f3f402da03fa3002db257 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Sat, 3 Dec 2022 18:27:47 +0100 Subject: [PATCH] Fix --- src/Psalm/Type/Reconciler.php | 12 +++++++++++- tests/TypeReconciliation/RedundantConditionTest.php | 12 ++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/Psalm/Type/Reconciler.php b/src/Psalm/Type/Reconciler.php index 003f6d290..3470aba0e 100644 --- a/src/Psalm/Type/Reconciler.php +++ b/src/Psalm/Type/Reconciler.php @@ -1140,7 +1140,17 @@ class Reconciler } else { $properties = $base_atomic_type->properties; $properties[$array_key_offset] = $result_type; - $base_atomic_type = $base_atomic_type->setProperties($properties); + if ($base_atomic_type->is_list && !isset($properties[$array_key_offset-1])) { + $base_atomic_type = new TKeyedArray( + $properties, + null, + $base_atomic_type->fallback_params, + false, + $base_atomic_type->from_docblock + ); + } else { + $base_atomic_type = $base_atomic_type->setProperties($properties); + } } $new_base_type = $new_base_type->getBuilder()->addType($base_atomic_type)->freeze(); diff --git a/tests/TypeReconciliation/RedundantConditionTest.php b/tests/TypeReconciliation/RedundantConditionTest.php index 2f43a7a1f..439142e8f 100644 --- a/tests/TypeReconciliation/RedundantConditionTest.php +++ b/tests/TypeReconciliation/RedundantConditionTest.php @@ -891,6 +891,18 @@ class RedundantConditionTest extends TestCase } }' ], + 'countWithNeverValuesInKeyedList' => [ + 'code' => ' [ 'code' => '