emacs-diffs
[Top][All Lists]
Advanced

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

master 27944247d16 4/4: Fix broken byte-compilation of unary comparisons


From: Mattias Engdegård
Subject: master 27944247d16 4/4: Fix broken byte-compilation of unary comparisons
Date: Wed, 26 Jul 2023 12:53:13 -0400 (EDT)

branch: master
commit 27944247d161f0ed65bbb34959c4493f7984987a
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>

    Fix broken byte-compilation of unary comparisons
    
    * lisp/emacs-lisp/byte-opt.el (byte-opt--nary-comparison):
    Fix a typo causing miscompilation of code such as (OP X),
    where OP is <, >, <=, >= or =.
    * test/lisp/emacs-lisp/bytecomp-tests.el
    (bytecomp-tests--test-cases): Add test case.
    
    Reported by Richard Copley.
---
 lisp/emacs-lisp/byte-opt.el            | 2 +-
 test/lisp/emacs-lisp/bytecomp-tests.el | 5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el
index 0be6ae65aab..3005d69ae88 100644
--- a/lisp/emacs-lisp/byte-opt.el
+++ b/lisp/emacs-lisp/byte-opt.el
@@ -973,7 +973,7 @@ for speeding up processing.")
   (let ((nargs (length (cdr form))))
     (cond
      ((= nargs 1)
-      `(progn (cadr form) t))
+      `(progn ,(cadr form) t))
      ((>= nargs 3)
       ;; At least 3 arguments: transform to N-1 binary comparisons,
       ;; since those have their own byte-ops which are particularly
diff --git a/test/lisp/emacs-lisp/bytecomp-tests.el 
b/test/lisp/emacs-lisp/bytecomp-tests.el
index b549ae1fe09..593fd117685 100644
--- a/test/lisp/emacs-lisp/bytecomp-tests.el
+++ b/test/lisp/emacs-lisp/bytecomp-tests.el
@@ -780,6 +780,11 @@ inner loops respectively."
     ;; (+ 0 -0.0) etc
     (let ((x (bytecomp-test-identity -0.0)))
       (list x (+ x) (+ 0 x) (+ x 0) (+ 1 2 -3 x) (+ 0 x 0)))
+
+    ;; Unary comparisons: keep side-effect, return t
+    (let ((x 0))
+      (list (= (setq x 1))
+            x))
     )
   "List of expressions for cross-testing interpreted and compiled code.")
 



reply via email to

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