Skip to content

Cherry-pick rule-application fixes from #301#303

Merged
arnog merged 5 commits into
mainfrom
pr301-cherry-picks
May 10, 2026
Merged

Cherry-pick rule-application fixes from #301#303
arnog merged 5 commits into
mainfrom
pr301-cherry-picks

Conversation

@arnog
Copy link
Copy Markdown
Member

@arnog arnog commented May 10, 2026

Summary

Cherry-picks 4 low-risk rule-application fixes from #301, plus regression tests. These fixes are independent of the larger expr.transform() feature and replace() API change in that PR, so they can land separately while the rest of #301 is still under review.

Commits

  • fix: do not return null in applyRule if replacement has applied recursively/to operands (adf26f80) — when a function-replace returns undefined at the top level, the operand-rewritten expression is now preserved instead of being silently discarded.
  • refactor: optimize rule application by exiting earlier on match-pattern canonical-variant wildcard loss (1bf80b5a) — pure optimization; same semantics, fewer wasted match attempts.
  • fix: parse object-Rule condition strings without $ delimiters and canonicalize (591f870b, squashed from 7d14b6a5 + ccd32d66) — previously, condition strings on object rules required $...$ LaTeX delimiters (otherwise silently dropped) and were parsed in raw form (so non-trivial expressions like a^2 > 0 couldn't evaluate). Both issues fixed.
  • refactor: singular documentative type-cast (2a44d4d7) — cosmetic, 1 line.

Tests

Three new regression tests in test/compute-engine/rules.test.ts covering each user-visible fix:

  1. applyRule preserves operand rewrites when function-replace returns undefined at top.
  2. Object-rule condition string without $ delimiters is honored.
  3. Object-rule condition string is canonicalized so it can evaluate.

Verification

  • 0 typecheck errors, 0 circular dependencies.
  • rules.test.ts: 23 / 23 pass (20 existing + 3 new).
  • Full test suite: 7867 passed, 12 todo, only the pre-existing flaky compile-performance memory test fails (machine-noise, fails identically on main).
  • Net change: +61/-35 across 3 files (rules.ts, boxed-function.ts, rules.test.ts).

Co-author preserved on each cherry-picked commit (samueltlg).

Test plan

  • npm run typecheck
  • npm run test compute-engine/rules
  • npm run test compute-engine/simplify
  • full jest suite (no new failures)

🤖 Generated with Claude Code

samueltlg and others added 5 commits May 9, 2026 17:39
…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>
@arnog arnog merged commit 8592aa8 into main May 10, 2026
1 of 3 checks passed
@arnog arnog deleted the pr301-cherry-picks branch May 10, 2026 01:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants