Don't hide not and null arity errors

* lisp/emacs-lisp/byte-opt.el (byte-optimize-not):
Don't silently convert incorrect `not` and `null` applications to nil.
This commit is contained in:
Mattias Engdegård 2024-06-17 13:14:08 +02:00
parent 175a513d19
commit 923aad81d4

View file

@ -1410,13 +1410,14 @@ See Info node `(elisp) Integer Basics'."
form)))
(defun byte-optimize-not (form)
(and (= (length form) 2)
(let ((arg (nth 1 form)))
(cond ((null arg) t)
((macroexp-const-p arg) nil)
((byte-compile-nilconstp arg) `(progn ,arg t))
((byte-compile-trueconstp arg) `(progn ,arg nil))
(t form)))))
(if (= (length form) 2)
(let ((arg (nth 1 form)))
(cond ((null arg) t)
((macroexp-const-p arg) nil)
((byte-compile-nilconstp arg) `(progn ,arg t))
((byte-compile-trueconstp arg) `(progn ,arg nil))
(t form)))
form))
(put 'and 'byte-optimizer #'byte-optimize-and)
(put 'or 'byte-optimizer #'byte-optimize-or)