diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/VariableFetchAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/VariableFetchAnalyzer.php index 5a3c5e4e6..93edbcfe6 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/VariableFetchAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/VariableFetchAnalyzer.php @@ -425,7 +425,8 @@ class VariableFetchAnalyzer && ($context->inside_call || $context->inside_conditional || $context->inside_use - || $context->inside_isset) + || $context->inside_isset + || $context->inside_throw) ) { if (!$stmt_type->parent_nodes) { $assignment_node = DataFlowNode::getForAssignment( diff --git a/tests/UnusedVariableTest.php b/tests/UnusedVariableTest.php index 85435e732..524db9d90 100644 --- a/tests/UnusedVariableTest.php +++ b/tests/UnusedVariableTest.php @@ -2300,6 +2300,23 @@ class UnusedVariableTest extends TestCase } }' ], + 'usedThrow' => [ + ' [ + '