Apply specified types in place on a batched working copy - #6168
Open
ondrejmirtes wants to merge 6 commits into
Open
Apply specified types in place on a batched working copy#6168ondrejmirtes wants to merge 6 commits into
ondrejmirtes wants to merge 6 commits into
Conversation
specifyExpressionType() derived one whole scope per specification - and one per array-dim level of the parent-intersection cascade. It now opens a single unpublished copy (openSpecificationScope) and writes holders straight into its maps (specifyExpressionTypeInPlace), resetting the lazily-derived views (resolvedTypes, truthy/falsey scopes, promoted-native scope) after each write so every read answers exactly as it did on a per-specification fresh scope. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DaBZjgksga4c5s6Q9FniY7
filterBySpecifiedTypes() chained addTypeToExpression()/removeTypeFromExpression(), deriving a whole scope per specification. The application loop now inlines their math and writes every consecutive specification into a single unpublished working copy; operations that go through other scope derivations (isset certainty, overwriting assignment) publish it and the next specification opens a fresh one. The conditional-expressions tail moves to processConditionalExpressionsAfterSpecifying(), mirroring the eventual applySpecifiedTypes() shape. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DaBZjgksga4c5s6Q9FniY7
…tries in The alternative-form entries of a SpecifiedTypes batch were appended after the sorted sure/sure-not list; sorting all three kinds together restores the shortest-expression-first guarantee (parents specified before their children) for them too. With the building inlined at its only caller, ScopeOps::buildTypeSpecifications() and its native mirror are removed. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DaBZjgksga4c5s6Q9FniY7
The method does not filter - it applies computed narrowing to the scope. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DaBZjgksga4c5s6Q9FniY7
The isset-certainty path of applySpecifiedTypes() re-read the expression's type via getType() before re-specifying it with Maybe certainty. getType() only reports the type of Yes-certainty holders, so for a maybe-defined expression it broadens to the original type - which would overwrite a co-applied narrowing (e.g. isset's $a -> null in the else branch). Read the held type from the holder maps instead. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DaBZjgksga4c5s6Q9FniY7
Member
Author
|
Benchmark (machine now quiet): commit-toggled ABBA, same tree, no-turbo,
Neutral within this run's noise floor — the value here is convergence (and the removed native mirror is a 1–3 element build+sort per application, so its deletion is micro). Happy to run a longer full self-analysis ABBA or a turbo-mode pair if wanted. |
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.
Applying a
SpecifiedTypesbatch derived one whole scope — a full holder-map copy plus scope construction — per specification, and one more per array-dim level of the parent-intersection cascade insidespecifyExpressionType(). This PR restructures the apply side to write in place:specifyExpressionType()opens a single unpublished copy (openSpecificationScope()) and writes holders straight into its maps (specifyExpressionTypeInPlace()). Every lazily-derived view (resolvedTypes, truthy/falsey scopes, the promoted-native scope) is reset after each write, so every read answers exactly as it did on a per-specification fresh scope.addTypeToExpression()/removeTypeFromExpression()math; operations that go through other scope derivations (isset certainty, overwriting assignment) publish it and the next specification opens a fresh one. The conditional-expressions tail moves toprocessConditionalExpressionsAfterSpecifying().ScopeOps::buildTypeSpecifications()and its native mirror are removed (smoke differential and signature parity green).filterBySpecifiedTypes()is renamed toapplySpecifiedTypes()— the method does not filter, it applies computed narrowing. It is public but not@api.getType(), which broadens Maybe-certainty holders and would overwrite a co-applied narrowing.Zero expectation churn: full test suite green in both turbo modes (17844 tests), self-analysis and CS clean, turbo smoke differential + signature parity green.
Benchmark note: the local machine is currently running a backup; I will post a commit-toggled ABBA user-CPU comparison as a comment once it quiets down.
🤖 Generated with Claude Code
https://claude.ai/code/session_01DaBZjgksga4c5s6Q9FniY7