Replay scope-deriving mutators in NodeCallbackScope answers - #6259
Merged
Conversation
NodeCallbackScope answers getType()/getNativeType() from the asked node's stored before-scope, which knows nothing about what a rule derived locally from the callback scope. filterByTruthyValue() and filterByFalseyValue() were already recorded and replayed onto the before-scope, but assignExpression(), assignVariable() and invalidateExpression() were not — a rule assigning a more specific type onto its scope read the original stored type right back. The recorded filters were also lost when the derivation chain passed through one of the unrecorded mutators. Record every scope-deriving call in one ordered list (replacing the separate truthy/falsey lists, whose replay was order-lossy between the two kinds) and replay it in call order in preprocessScope(). Only top-level calls are recorded: a mutator implemented via other mutators resets the list to its caller's view and appends itself, and the replay re-runs the composition. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K2oPPwjrXy88MUsYekCFQ6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
NodeCallbackScope answers
getType()/getNativeType()from the asked node's stored before-scope, which knows nothing about what a rule derived locally from the callback scope.filterByTruthyValue()andfilterByFalseyValue()were already recorded and replayed onto the before-scope, butassignExpression(),assignVariable()andinvalidateExpression()were not — a rule assigning a more specific type onto its scope read the original stored type right back. The recorded filters were also lost when the derivation chain passed through one of the unrecorded mutators.This is a regression against 2.2.8 (pre-NodeCallbackScope) hit in the wild: ShipMonk's InputDocumentor assigns caller-side constant argument types onto the scope of a callee body it re-analyses via
NodeScopeResolver::processNodes(), then expectsgetType()on an argument variable to see the constant — on current 2.2.x it saw the generalizedstringand aborted the analysis with "Internal error: Unexpected argument analysed …".The fix records every scope-deriving call in one ordered list (replacing the separate truthy/falsey lists, whose replay was order-lossy between the two kinds) and replays it in call order in
preprocessScope(). Only top-level calls are recorded: a mutator implemented via other mutators (assignVariable()callsassignExpression()) resets the list to its caller's view and appends itself, and the replay re-runs the composition.The new test fails before the fix with all four probes reporting the stale generalized types (the filter-then-assign probe also demonstrates the filter loss:
string|null).🤖 Generated with Claude Code
https://claude.ai/code/session_01K2oPPwjrXy88MUsYekCFQ6