Repository navigation
Conversation
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.
Nested matches inside a repeated abstraction argument can have their savings counted twice, although rewriting the outer match retains the argument only once. This makes the predicted cost disagree with
rewrite_fastand triggers the mismatch assertion.Minimal example (default costs):
The original costs 1312, and the rewrite costs 706. The inner rewrite saves 101. The old prediction is 605: it also counts the savings in the copy removed by the outer rewrite. With definition cost 104, net utility should be 502.
For candidates with repeated arguments, compute marginal savings bottom-up by comparing:
Memoize subtree utility, then pass the marginal deltas through the existing root/task/weight aggregation. Candidates without repeated arguments keep the existing path. Cost weights, pruning flags and mismatch assertions are unchanged.
Five standalone Rust regressions cover the exact example, nonmatching wrappers and nesting depths, lambda scope, overlapping matches, and weighted/task-grouped inputs. The original four unweighted regression cases fail on the base; all five pass with this patch.
Validation (macOS arm64, Rust 1.94.0):
cargo test --release --test nested_multiuse: 5 passed.python_symbols_regressionfiltered out on this branch.cargo clippy --no-deps -- -Dwarnings: passed.A full fuzz baseline on unmodified
350804bproduced 98 passes and two existing 600-second timeouts (seeds 62 and 81); full patched fuzz coverage remains unverified. I checked the open optimization PRs #195 and #244: they target older correction code and do not contain this fix. The historical mismatch report #129 has a similar symptom, but this PR does not assume it has the same root cause.This change is independent of the rejected-pattern/
utility_by_rewritecrash fix.