Skip to content

Numerator, Denominator and NumeratorDenominator keep extra operands when they canonicalize - #443

Closed
enumeratio wants to merge 3 commits into
cortex-js:mainfrom
enumeratio:numerator-extra-operands
Closed

enumeratio wants to merge 3 commits into
cortex-js:mainfrom
enumeratio:numerator-extra-operands

Conversation

@enumeratio

Copy link
Copy Markdown
Contributor

Fix #442.

The quotient shortcut in their canonical handlers now applies only to a one-operand call, so Numerator(a/b, x) stays a call instead of becoming a. Numerator(a/b) is unchanged.

…rtcut only for a one-operand call, so extra operands survive canonicalization. Fix #ISSUE
@arnog

arnog commented Oct 16, 2026

Copy link
Copy Markdown
Member

Thank you, this is landed on main in f601dee (commit, not merge, so the PR is closed rather than merged). It ships in the next release.

Two additions beyond the PR:

  • The rational-literal shortcut of Denominator and NumeratorDenominator (a first operand such as 5 or 3/4 read by asRational) had the same gap: Denominator(5, x) still canonicalized to 1. It now carries the same one-operand guard.
  • The built-in evaluate handlers refuse a call with more than one operand, the way every other one-operand operator does: Numerator(a/b, x) and Numerator(c, x) evaluate to Error("unexpected-argument", "x") with the frame (Numerator, 2). The canonical form keeps the operands, as in your PR, so a definition that replaces the evaluate handler sees them. The refusal is one error for the whole call, before any broadcast: Denominator(5, []) is the error, not []. An empty Sequence or a Nothing operand does not count as an operand.

Fixes #442.

@arnog arnog closed this Oct 16, 2026
enumeratio added a commit to enumeratio/enumeratio that referenced this pull request Oct 21, 2026
…cessary (BL-183) (#1031)

Numerator/Denominator keep their extra operands through canonicalization since compute-engine 0.159 (cortex-js/compute-engine#443), so the `canonical` override that rebuilt the call through private `ce._fn` is gone.

Still ours: the `tuples` broadcast exemption (the trailing `Over -> R` rule is a Tuple; 0.159's native `surplus-operands` alone still lets it thread). It is now set through `extendHead` (new `broadcastExemptions` field on `HeadPatch`) rather than by mutating the definition. Numerator stays in the provenance OVERRIDDEN list: compute-engine ignores `Over`, ours reads the ring. No example rows or `expected` values change.
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.

Numerator(a/b, x) canonicalizes to a, dropping x

2 participants