From 070c80ee06664c90fb9c96a1b9c89f7b844ae712 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mattias=20Engdeg=C3=A5rd?= Date: Wed, 21 Jul 2021 10:54:43 +0200 Subject: [PATCH] Fix mistake in `quote` optimiser Found by Pip Cet. * lisp/emacs-lisp/byte-opt.el (byte-optimize-quote): Fix mistake that made this optimiser ineffective at removing quoting of nil, t, and keywords. The only obvious consequence is that we no longer need... (byte-optimize-form): ...a 'nil => nil normalising step here; remove. (byte-optimize-form-code-walker): Make the compiler warn about (quote). --- lisp/emacs-lisp/byte-opt.el | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el index c9c0ac0045e..341643c7d16 100644 --- a/lisp/emacs-lisp/byte-opt.el +++ b/lisp/emacs-lisp/byte-opt.el @@ -414,7 +414,7 @@ Same format as `byte-optimize--lexvars', with shared structure and contents.") form))) (t form))) (`(quote . ,v) - (if (cdr v) + (if (or (not v) (cdr v)) (byte-compile-warn "malformed quote form: `%s'" (prin1-to-string form))) ;; Map (quote nil) to nil to simplify optimizer logic. @@ -667,8 +667,7 @@ Same format as `byte-optimize--lexvars', with shared structure and contents.") (byte-compile-log " %s\t==>\t%s" old new) (setq form new) (not (eq new old)))))))) - ;; Normalise (quote nil) to nil, for a single representation of constant nil. - (and (not (equal form '(quote nil))) form)) + form) (defun byte-optimize-let-form (head form for-effect) ;; Recursively enter the optimizer for the bindings and body @@ -1077,7 +1076,7 @@ See Info node `(elisp) Integer Basics'." (defun byte-optimize-quote (form) (if (or (consp (nth 1 form)) (and (symbolp (nth 1 form)) - (not (macroexp--const-symbol-p form)))) + (not (macroexp--const-symbol-p (nth 1 form))))) form (nth 1 form))) -- 2.39.2