Subject: Re: bug#76447: 29.4; ert-run-tests-batch now aborts if a test signals an undefined error

From: Stefan Monnier <[email-masked]>
Date: Sat, 15 Mar 2025 09:57:52 -0400

>> test-2 isn't executed.  I think the Emacs 29.4 behavior is more
>> "user-friendly", though this (signaling an error symbol that doesn't
>> derive from 'error') is arguably a corner case.

Indeed, it really should never happen.  Similarly `ignore-errors` will
not catch your `foo` signal.  I don't think it's a problem in ERT.

But maybe we should make `signal` signal an error if the provided
error-symbol is not a valid error condition symbol, as in the patch below?

>> Probably the behavior change is fallout from switching to handler-bind.
>> To restore the Emacs 29.4 behavior, probably a construct such as
>> 
>> (condition-case err
>>     (handler-bind ((t ...)) ...)
>>   (t ...))

I think `(handler-bind ((t ...)) ...)` would be sufficient, since there
is currently no `condition-case` in the corresponding code.

        Stefan

diff --git a/src/eval.c b/src/eval.c
index 5de723cf3bc..6d87d274c31 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -1860,6 +1860,8 @@ signal_or_quit (Lisp_Object error_symbol, Lisp_Object data, bool continuable)
     }
 
   conditions = Fget (real_error_symbol, Qerror_conditions);
+  if (NILP (conditions))
+    signal_error ("Invalid error symbol", error_symbol);
 
   /* Remember from where signal was called.  Skip over the frame for
      `signal' itself.  If a frame for `error' follows, skip that,