diff --git a/src/Analyser/NodeScopeResolver.php b/src/Analyser/NodeScopeResolver.php index 3af8aba73f..043ae8943c 100644 --- a/src/Analyser/NodeScopeResolver.php +++ b/src/Analyser/NodeScopeResolver.php @@ -4343,9 +4343,11 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto $matchScope = $matchScope->filterByFalseyValue($filteringExpr); } - $remainingType = $matchScope->getType($expr->cond); - if (!$hasDefaultCond && !$hasAlwaysTrueCond && !$remainingType instanceof NeverType) { - $throwPoints[] = InternalThrowPoint::createExplicit($scope, new ObjectType(UnhandledMatchError::class), $expr, false); + if (!$hasDefaultCond && !$hasAlwaysTrueCond) { + $remainingType = $matchScope->getType($expr->cond); + if (!$remainingType instanceof NeverType) { + $throwPoints[] = InternalThrowPoint::createExplicit($scope, new ObjectType(UnhandledMatchError::class), $expr, false); + } } ksort($armNodes, SORT_NUMERIC);