Skip to content

Commit 346dfbb

Browse files
ondrejmirtesclaude
andcommitted
Read operand types from ExpressionResults in Throw/BooleanAnd/Coalesce handlers
Where the handler already holds the child's ExpressionResult, read the type off the result instead of re-asking the scope: the throw point's thrown type and the two right-side explicit-never checks. First batch of converting handler Scope::getType() reads to ExpressionResult reads - the call sites then match the single-pass engine, which answers them from the result without a scope walk. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019wqGgaD7iqL44t1KgpJS7b
1 parent 2044bb0 commit 346dfbb

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

src/Analyser/ExprHandler/BooleanAndHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ public function processExpr(NodeScopeResolver $nodeScopeResolver, Stmt $stmt, Ex
265265
$leftResult = $nodeScopeResolver->processExprNode($stmt, $expr->left, $scope, $storage, $nodeCallback, $context->enterDeep());
266266
$leftTruthyScope = $leftResult->getTruthyScope();
267267
$rightResult = $nodeScopeResolver->processExprNode($stmt, $expr->right, $leftTruthyScope, $storage, $nodeCallback, $context);
268-
$rightExprType = $rightResult->getScope()->getType($expr->right);
268+
$rightExprType = $rightResult->getType();
269269
if ($rightExprType instanceof NeverType && $rightExprType->isExplicit()) {
270270
$leftMergedWithRightScope = $leftResult->getFalseyScope();
271271
} else {

src/Analyser/ExprHandler/CoalesceHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public function processExpr(NodeScopeResolver $nodeScopeResolver, Stmt $stmt, Ex
128128

129129
$rightScope = $scope->filterByFalseyValue($expr);
130130
$rightResult = $nodeScopeResolver->processExprNode($stmt, $expr->right, $rightScope, $storage, $nodeCallback, $context->enterDeep());
131-
$rightExprType = $scope->getType($expr->right);
131+
$rightExprType = $rightResult->getType();
132132
if ($rightExprType instanceof NeverType && $rightExprType->isExplicit()) {
133133
$scope = $scope->filterByTruthyValue(new Expr\Isset_([$expr->left]));
134134
} else {

src/Analyser/ExprHandler/ThrowHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function processExpr(NodeScopeResolver $nodeScopeResolver, Stmt $stmt, Ex
4848
expr: $expr,
4949
hasYield: false,
5050
isAlwaysTerminating: true,
51-
throwPoints: array_merge($exprResult->getThrowPoints(), [InternalThrowPoint::createExplicit($scope, $scope->getType($expr->expr), $expr, false)]),
51+
throwPoints: array_merge($exprResult->getThrowPoints(), [InternalThrowPoint::createExplicit($scope, $exprResult->getType(), $expr, false)]),
5252
impurePoints: $exprResult->getImpurePoints(),
5353
);
5454
}

0 commit comments

Comments
 (0)