diff --git a/src/Psalm/Internal/Type/Comparator/AtomicTypeComparator.php b/src/Psalm/Internal/Type/Comparator/AtomicTypeComparator.php index 66ac41c31..0d0229521 100644 --- a/src/Psalm/Internal/Type/Comparator/AtomicTypeComparator.php +++ b/src/Psalm/Internal/Type/Comparator/AtomicTypeComparator.php @@ -358,7 +358,6 @@ class AtomicTypeComparator if ($allow_interface_equality || ($input_type_part instanceof TArray && !$input_type_part->type_params[1]->isEmpty()) - || $input_type_part instanceof TKeyedArray ) { return true; } diff --git a/tests/Template/FunctionTemplateTest.php b/tests/Template/FunctionTemplateTest.php index 607f07cd9..eef306eac 100644 --- a/tests/Template/FunctionTemplateTest.php +++ b/tests/Template/FunctionTemplateTest.php @@ -2090,6 +2090,31 @@ class FunctionTemplateTest extends TestCase createProxy(A::class, \'Ns\foo\')->bar();', 'error_message' => 'InvalidArgument' ], + 'preventBadArraySubtyping' => [ + ' 123]; + return $b; + }', + 'error_message' => 'InvalidReturnStatement' + ], + 'modifyTemplatedShape' => [ + ' 'InvalidReturnStatement' + ], ]; } }