Subject: bug#58396: 29.0.50; Optimization failure for add-to-list

From: Stefan Monnier <[email-masked]>
Date: Sat, 30 Sep 2023 09:56:09 -0400

> +                  (let ((inhibit-message t)     ;[1]
> +                        (warning-minimum-log-level :emergency))
>                      (advice-add 'macroexpand :around macroexpand-advice)
> -                    (macroexpand-all sexp))
> +                    (condition-case nil         ;[3]
> +                        (macroexpand-all sexp)
> +                      (t sexp)))

This `t` catches more than errors.  Better replace it with `error`.

> -                  (let ((warning-minimum-log-level :emergency))
> +                  (let ((inhibit-message t)                  ;[1]
> +                        (macroexp-inhibit-compiler-macros t) ;[2]
> +                        (warning-minimum-log-level :emergency))
>                      (advice-add 'macroexpand-1 :around macroexpand-advice)
> -                    (macroexpand-all sexp elisp--local-macroenv))
> +                    (condition-case nil         ;[3]
> +                        (macroexpand-all sexp elisp--local-macroenv)
> +                      (t sexp)))

What kind of errors are we expecting to catch with this
`condition-case`?  The pre-existing advice is supposed to catch macro
expansion errors, and the new let-binding is supposed to catch
compiler-macro errors, so it seems to me there aren't any *expected*
errors left.  If so, better remove this `condition-case` (or replace it
with `with-demoted-errors`) since all it has left to do is to hide any
real coding error that may come up and that we'd like to be told about.

        Stefan