New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MatchExpressionArmBody #1726
MatchExpressionArmBody #1726
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically in both cases we should use the scope that's used in processExprNode
when processsing the body expr. It's quite intuitive actually :)
src/Analyser/NodeScopeResolver.php
Outdated
@@ -2633,7 +2635,8 @@ static function (Node $node, Scope $scope) use ($nodeCallback): void { | |||
$filteringExpr = new BinaryOp\BooleanOr($filteringExpr, $armCondExpr); | |||
} | |||
|
|||
$armNodes[] = new MatchExpressionArm($condNodes, $arm->getLine()); | |||
$matchArmBody = new MatchExpressionArmBody($armCondScope, $arm->body); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the correct scope here is the one that's created below in processExprNode call - $matchScope->filterByTruthyValue($filteringExpr)
but please test that :)
src/Analyser/NodeScopeResolver.php
Outdated
@@ -2603,7 +2604,8 @@ static function (Node $node, Scope $scope) use ($nodeCallback): void { | |||
$hasYield = $hasYield || $armResult->hasYield(); | |||
$throwPoints = array_merge($throwPoints, $armResult->getThrowPoints()); | |||
$scope = $scope->mergeWith($matchScope); | |||
$armNodes[] = new MatchExpressionArm([], $arm->getLine()); | |||
$matchArmBody = new MatchExpressionArmBody($scope, $arm->body); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the right scope here is $matchScope
. But the one that's correct at the beginning of the foreach, before it's rewritten with $matchScope = $armResult->getScope();
.
1306b4c
to
738ee83
Compare
I fixed the issues and merged this. Consider it a gift to your newborn 😄 |
No description provided.