aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias EngdegÄrd2025-10-28 17:01:35 +0100
committerMattias EngdegÄrd2025-10-30 12:12:35 +0100
commit85e1a649439ef4d96cbdeeb91c46a1b49ea22d00 (patch)
tree77c526111d181a370a1da1b5dfa78a77c6ff7e90
parent0fb8ed8c71c6447b4d4ecb06550bfc1aa3b4cee6 (diff)
downloademacs-85e1a649439ef4d96cbdeeb91c46a1b49ea22d00.tar.gz
emacs-85e1a649439ef4d96cbdeeb91c46a1b49ea22d00.zip
Fix numeric comparison bug when optimisation is disabled
* lisp/emacs-lisp/bytecomp.el (byte-compile-cmp): Don't assume that N-ary comparisons have been normalised, which is done in the optimiser. Reported by Pip Cet.
-rw-r--r--lisp/emacs-lisp/bytecomp.el28
1 files changed, 16 insertions, 12 deletions
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index 7c652b0c6fb..b016b04c2d3 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -4069,18 +4069,22 @@ If it is nil, then the handler is \"byte-compile-SYMBOL.\""
4069 4069
4070(defun byte-compile-cmp (form) 4070(defun byte-compile-cmp (form)
4071 "Compile calls to numeric comparisons such as `<', `=' etc." 4071 "Compile calls to numeric comparisons such as `<', `=' etc."
4072 ;; Lisp-level transforms should already have reduced valid calls to 2 args. 4072 ;; Lisp-level transforms should already have reduced valid calls to 2 args,
4073 (if (not (= (length form) 3)) 4073 ;; but optimisations may have been disabled.
4074 (byte-compile-subr-wrong-args form "1 or more") 4074 (let ((l (length form)))
4075 (byte-compile-two-args 4075 (cond
4076 (if (macroexp-const-p (nth 1 form)) 4076 ((= l 3)
4077 ;; First argument is constant: flip it so that the constant 4077 (byte-compile-two-args
4078 ;; is last, which may allow more lapcode optimizations. 4078 (if (macroexp-const-p (nth 1 form))
4079 (let* ((op (car form)) 4079 ;; First argument is constant: flip it so that the constant
4080 (flipped-op (cdr (assq op '((< . >) (<= . >=) 4080 ;; is last, which may allow more lapcode optimizations.
4081 (> . <) (>= . <=) (= . =)))))) 4081 (let* ((op (car form))
4082 (list flipped-op (nth 2 form) (nth 1 form))) 4082 (flipped-op (cdr (assq op '((< . >) (<= . >=)
4083 form)))) 4083 (> . <) (>= . <=) (= . =))))))
4084 (list flipped-op (nth 2 form) (nth 1 form)))
4085 form)))
4086 ((= l 2) (byte-compile-form `(progn ,(nth 1 form) t)))
4087 (t (byte-compile-normal-call form)))))
4084 4088
4085(defun byte-compile-three-args (form) 4089(defun byte-compile-three-args (form)
4086 (if (not (= (length form) 4)) 4090 (if (not (= (length form) 4))