Cherry-pick rule-application fixes from #301#303
Merged
Conversation
…ecursively/to operands
…rn canonical-variant wildcard loss
…anonicalize - Drop the '$...$' wrapping requirement so bare LaTeX condition strings parse correctly via ce.parse(). - Always canonicalize the condition so it can evaluate against substitutions. Co-Authored-By: samueltlg <samueltlgg@gmail.com>
Three tests covering the fixes from PR #301 commits 2bd9953, 591f870: - applyRule preserves operand rewrites when function-replace returns undefined at top (tests the !result early-return path). - Object-rule condition string without '$' delimiters is honored (tests parsing of bare LaTeX condition strings). - Object-rule condition string is canonicalized so it can evaluate (tests that non-trivial conditions like 'a^2 > 0' work). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
Cherry-picks 4 low-risk rule-application fixes from #301, plus regression tests. These fixes are independent of the larger
expr.transform()feature andreplace()API change in that PR, so they can land separately while the rest of #301 is still under review.Commits
nullinapplyRuleif replacement has applied recursively/to operands (adf26f80) — when a function-replace returnsundefinedat the top level, the operand-rewritten expression is now preserved instead of being silently discarded.1bf80b5a) — pure optimization; same semantics, fewer wasted match attempts.$delimiters and canonicalize (591f870b, squashed from7d14b6a5+ccd32d66) — previously, condition strings on object rules required$...$LaTeX delimiters (otherwise silently dropped) and were parsed inrawform (so non-trivial expressions likea^2 > 0couldn't evaluate). Both issues fixed.2a44d4d7) — cosmetic, 1 line.Tests
Three new regression tests in
test/compute-engine/rules.test.tscovering each user-visible fix:applyRulepreserves operand rewrites when function-replace returnsundefinedat top.$delimiters is honored.Verification
rules.test.ts: 23 / 23 pass (20 existing + 3 new).compile-performancememory test fails (machine-noise, fails identically onmain).rules.ts,boxed-function.ts,rules.test.ts).Co-author preserved on each cherry-picked commit (samueltlg).
Test plan
npm run typechecknpm run test compute-engine/rulesnpm run test compute-engine/simplify🤖 Generated with Claude Code