diff --git a/src/Psalm/Type/Reconciler.php b/src/Psalm/Type/Reconciler.php index 1a41feb12..9d653dd9e 100644 --- a/src/Psalm/Type/Reconciler.php +++ b/src/Psalm/Type/Reconciler.php @@ -59,8 +59,8 @@ class Reconciler CodeLocation $code_location = null, array $suppressed_issues = [] ) { - foreach ($new_types as $nk => $_) { - if (strpos($nk, '[')) { + foreach ($new_types as $nk => $type) { + if (strpos($nk, '[') && ($type === '^isset' || $type === '!^empty')) { $path_parts = self::breakUpPathIntoParts($nk); if (count($path_parts) > 1) { diff --git a/tests/ValueTest.php b/tests/ValueTest.php index 234287fb7..6f1c6c0ef 100644 --- a/tests/ValueTest.php +++ b/tests/ValueTest.php @@ -153,15 +153,58 @@ class ValueTest extends TestCase takesInt($i); }', ], - 'regularStringComparison' => [ + 'regularComparison1' => [ ' [ + ' [ + ' [ + '