diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/AssignmentAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/AssignmentAnalyzer.php index 38dc50475..445c1cb11 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/AssignmentAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/AssignmentAnalyzer.php @@ -1884,6 +1884,11 @@ class AssignmentAnalyzer $codebase ); + $right_clauses = Context::filterClauses( + $var_id, + $right_clauses + ); + $assignment_clauses = \Psalm\Internal\Algebra::combineOredClauses( [new \Psalm\Internal\Clause([$var_id => ['falsy']], $var_object_id, $var_object_id)], $right_clauses, diff --git a/tests/TypeReconciliation/TypeAlgebraTest.php b/tests/TypeReconciliation/TypeAlgebraTest.php index b1d23aa1a..2db7d12c8 100644 --- a/tests/TypeReconciliation/TypeAlgebraTest.php +++ b/tests/TypeReconciliation/TypeAlgebraTest.php @@ -1052,6 +1052,13 @@ class TypeAlgebraTest extends \Psalm\Tests\TestCase } }' ], + 'assignSameName' => [ + '