Subject: Re: bug#18154: 24.4.50; eval-buffer ignores debug-on-error sometimes

From: Stefan Monnier <[email-masked]>
Date: Wed, 06 Aug 2014 13:11:51 -0400

> Starting Emacs with:
>   emacs -Q -nw \
>       -eval '(setq debug-on-error t)' \
>       -eval '(insert "(defun f () (push))")' \
>       -f eval-buffer

> only prints this message: 

>   Eager macro-expansion failure: (wrong-number-of-arguments (2 . 2) 0)

> This is not what I expect; Emacs should enter the debugger instead.

The eager-macroexpansion is not indispensable (so far), so any errors
that happen during it are demoted to mere warnings (like the line you
quote above).  Hence debug-on-error doesn't cause you to get
a backtrace.  You'd need to use debug-on-signal for that.

But you should indeed be dropped into the debugger if/when you call `f'
(unless you redefine `push' to accept 0 arguments before you call `f',
obviously).

> If "(defun f () (push))" is replaced by "(/ 1 0)" then the
> debugger pops up as expected.

Of course.  Note that when (defun f () (push)) is evaluated, it just
defines `f' but doesn't actually run `push' (tho eager-macroexpansion
tries to macroexpand `push' in the hope to avoid having to do it
every time `f' gets called).

        Stefan