On Wed, 04 Mar 2026, Werner LEMBERG <[email protected]> wrote:
> Is there any progress in fixing this glitch?

It seems that the combinaison of the optimization passes
`#:expand-primitives?' and `#:resolve-primitives?' will always optimize
the expression in a way that introduce a 0 as the second argument.

With some `pk' in language/tree-il/optimize.scm:

  scheme@(guile-user>) ,option optimization-level 1
  scheme@(guile-user>) ,optimize (- x )
  ...
  ;;; (starting-pass #<procedure resolve-primitives (x mod)>)

  ;;; (before #<tree-il (call (toplevel -) (toplevel x))>)

  ;;; (after #<tree-il (primcall - (toplevel x))>)

  ;;; (starting-pass #<procedure expand-primitives (x)>)

  ;;; (before #<tree-il (primcall - (toplevel x))>)

  ;;; (after #<tree-il (primcall - (const 0) (toplevel x))>)
  ...

To something is happening when expanding: (primcall - (toplevel x))

I'll continue digging.  But looking at the intrinsics `sub', which is
`scm_difference', it is fine for the second parameter to be unbound, in
which case the negation of the first parameter is return or a dispatch
is made when not a number.

However, I think that the VM always requires two argument for the
intrinsic.  I guess it is a matter of changing the value of the
immediate value to be the undefined value.

Thanks,
Olivier
-- 
Olivier Dion




Reply via email to