Subject: Re: bug#69573: Eager macro-expansion failure: (wrong-type-argument integer-or-marker-p nil)

From: Stefan Monnier <[email-masked]>
Date: Sat, 09 Mar 2024 09:47:06 -0500

>> (defalias 're-search-forward-ifpmod (symbol-function 're-search-forward) ...)
[...]
> Stefan, can you help maybe?  Gabriele then does this:
[...]
> and we have found that this causes weird errors because at least some
> definitions, like `forward-paragraph', call `re-search-forward-ifpmod'
> afterwards.  This seems to happen only when using a native compiled

Sounds like a problem in the code that installs trampolines.

Andrea?

If we look at `fset`, the C code does:

    if (!NILP (Vnative_comp_enable_subr_trampolines)
        && SUBRP (function)
        && !SUBR_NATIVE_COMPILEDP (function))
      CALLN (Ffuncall, Qcomp_subr_trampoline_install, symbol);

so indeed if the SUBR_NATIVE_COMPILEDP function is stored in another
symbol, we will still call Qcomp_subr_trampoline_install, even tho it's
a case where it should not be necessary, and I suspect this can lead to
the kind of problems mentioned above, if we do something like

    (defalias 'foo (symbol-function 'bar))
    (fset 'foo <something-else>)

where native calls to `bar` could end up redirected to the definition of
`foo` :-(

        Stefan