bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#39385: Erroneous interaction of eval-when-compile and condition-case


From: Alan Mackenzie
Subject: bug#39385: Erroneous interaction of eval-when-compile and condition-case
Date: Sat, 1 Feb 2020 21:47:31 +0000
User-agent: Mutt/1.10.1 (2018-07-13)

Hello, Emacs.

On master, with emacs -Q.

Create the following file, bad-eval-when-compile.el:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defmacro c-safe (&rest body)
  ;; safely execute BODY, return nil if an error occurred
  `(condition-case nil
       (progn ,@body)
     (error nil)))

(defmacro foo ()
  (error "This message should not be seen"))

(eval-when-compile
  (c-safe (foo)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Now do M-x byte-compile-file <CR> bad-eval-when-compile.el <CR>.  This
erroneously throws the error:

    This message should not be seen

.  This should have been caught by the condition-case generated by
(c-safe ...).

As a matter of interest, if eval-when-compile is replaced by
cc-eval-when-compile:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defmacro cc-eval-when-compile (&rest body)
  `(eval-when-compile
    (eval '(progn ,@body))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

, then the compilation succeeds.  So it would appear that there is a bug
in the byte compiler's handling of eval-when-compile.

-- 
Alan Mackenzie (Nuremberg, Germany).





reply via email to

[Prev in Thread] Current Thread [Next in Thread]