Skip to content

Commit f061789

Browse files
ondrejmirtesclaude
andcommitted
Fire the list item callback after its key is processed
InvalidKeyInArrayItemRule reads the key's type from the item node; firing the callback after the key walk lets it consume the stored key result instead of pricing the node ahead of its walk - the same order the literal-array handler uses. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01R7pqAkCx4xP6WYxBo2nMJE
1 parent 3c2f3af commit f061789

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

‎src/Analyser/ExprHandler/AssignHandler.php‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1523,7 +1523,6 @@ public function applyWrite(
15231523
$itemScope = $itemScope->enterExpressionAssign($arrayItem->value);
15241524
}
15251525
$itemScope = $nodeScopeResolver->lookForSetAllowedUndefinedExpressions($itemScope, $arrayItem->value);
1526-
$nodeScopeResolver->callNodeCallback($nodeCallback, $arrayItem, $itemScope, $storage);
15271526
$keyResult = null;
15281527
if ($arrayItem->key !== null) {
15291528
$keyResult = $nodeScopeResolver->processExprNode($stmt, $arrayItem->key, $itemScope, $storage, $nodeCallback, $context->enterDeep());
@@ -1533,6 +1532,10 @@ public function applyWrite(
15331532
$isAlwaysTerminating = $isAlwaysTerminating || $keyResult->isAlwaysTerminating();
15341533
$scope = $keyResult->getScope();
15351534
}
1535+
// the item fires after its key so a rule reading the key's type
1536+
// consumes the key's result instead of pricing the node ahead of
1537+
// its walk (the literal-array handler orders the two the same way)
1538+
$nodeScopeResolver->callNodeCallback($nodeCallback, $arrayItem, $itemScope, $storage);
15361539

15371540
if ($keyResult !== null) {
15381541
$dimType = $keyResult->getTypeOnScope($scope, $scope->nativeTypesPromoted);

0 commit comments

Comments
 (0)