On Wed, 04 Mar 2026, Olivier Dion <[email protected]> wrote:
> On Wed, 04 Mar 2026, Werner LEMBERG <[email protected]> wrote:
>> Is there any progress in fixing this glitch?
[...]
> To something is happening when expanding: (primcall - (toplevel x))
So the culprit is in languages/tree-il/primitives.scm:
(define-primitive-expander -
(x) (- 0 x) ; <- here
(x y) (- x y)
(x y z ... last) (- (- x y . z) last))
introduced by cb28c08537790b49f7bc94f2f6b426497152bbe7
If I remove the 0, it seems to be okay and no tests are failing. I
wonder why Andy decides to put this expansion.
There seems to be similar expansions for a couple of primitive generics:
(define-primitive-expander zero? (x)
(= x 0))
(define-primitive-expander positive? (x)
(> x 0))
(define-primitive-expander negative? (x)
(< x 0))
(define-primitive-expander /
(x) (/ 1 x) ; <- here
(x y z ... last) (/ (/ x y . z) last))
I think it is fine to remove the expander for the `(x)' case for `-' and
`/', but not for the predicates. Thoughts?
Thanks,
Olivier
--
Olivier Dion