Deduplicate UCS splits using LetSplit and UseSplit#486
Open
chengluyu wants to merge 12 commits into
Open
Conversation
# Conflicts: # hkmc2/shared/src/test/mlscript/block-staging/Functions.mls # hkmc2/shared/src/test/mlscript/codegen/MergeMatchArms.mls # hkmc2/shared/src/test/mlscript/ucs/general/LogicalConnectives.mls # hkmc2/shared/src/test/mlscript/ucs/normalization/Deduplication.mls
In `normalizeImpl`, when the alternative references the same scrutinee as the current branch, the alternative is duplicated and specialized separately in `+` and `-` modes. When both specializations agree, the two duplicates could in principle be shared via a single `LetSplit`. That detection is not yet implemented; mark the bail-out site with a TODO and add `SpecializedSplitSharing.mls` covering both: - cases where the duplication is wasteful (disjoint sibling classes like `Cat()`/`Dog()` — both specializations agree, sharing would suffice); - cases where the duplication is genuine (refining patterns like `S(0)`/`S(_)` — positive and negative specialization yield different splits, sharing would be incorrect). The latter group guards against a future over-eager sharing rule. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The `Split.Else` branch of the `++` extension was annotated as impossible but silently discarded `those`. Replace the comment with a `softAssert(false)` so that the invariant is enforced at runtime and visible in stack traces if it ever breaks. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
`JoinPointCtx` tracks the pending set of `SplitSymbol`s awaiting a `LetSplit` placement — a piece of state genuinely local to the walk. Stashing the sharing threshold in the same case class forced a plumbing trick where an inner `normalize` call had to reconstruct the context with `JoinPointCtx.withThreshold` just to carry a config option across an invocation boundary. The threshold is the only `Config` field `normalize` needs, and the caller already has `Config` in scope. Just add `Config` to the class constructor's `using` clause so all methods can read it via the global `config` helper, drop the parameter from `apply`, and simplify `JoinPointCtx` back to the symbol set it was originally. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Contributor
|
Pls fix the conflicts. |
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.
No description provided.