From e22e0ac92c676bb48f54582c11c66d731a4bc581 Mon Sep 17 00:00:00 2001 From: Brown Date: Wed, 24 Jul 2019 16:53:14 -0400 Subject: [PATCH] Fix unused ref in assign op Fixes #1968 --- .../Analyzer/Statements/Expression/AssignmentAnalyzer.php | 1 + tests/UnusedVariableTest.php | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/AssignmentAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/AssignmentAnalyzer.php index d343ed254..feaa1fefa 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/AssignmentAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/AssignmentAnalyzer.php @@ -847,6 +847,7 @@ class AssignmentAnalyzer if ($lhs_var_id) { $context->vars_in_scope[$lhs_var_id] = Type::getMixed(); + $context->hasVariable($lhs_var_id, $statements_analyzer); } if ($rhs_var_id) { diff --git a/tests/UnusedVariableTest.php b/tests/UnusedVariableTest.php index e318078ce..899009fe5 100644 --- a/tests/UnusedVariableTest.php +++ b/tests/UnusedVariableTest.php @@ -1002,6 +1002,13 @@ class UnusedVariableTest extends TestCase } }', ], + 'varPassedByRef' => [ + '