]> git.eshelyaron.com Git - emacs.git/commitdiff
Repair miscompilation of single-arg `apply` (bug#69533)
authorMattias EngdegÄrd <mattiase@acm.org>
Mon, 4 Mar 2024 09:44:19 +0000 (10:44 +0100)
committerEshel Yaron <me@eshelyaron.com>
Tue, 5 Mar 2024 15:34:06 +0000 (16:34 +0100)
* lisp/emacs-lisp/byte-opt.el (byte-optimize-apply):
Don't optimise single-argument `apply`; it's a legacy construct.
* test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-tests--test-cases):
Add test case.

(cherry picked from commit b9e8474a4470f71c30a4b89651fd3c5f2ef92ba2)

lisp/emacs-lisp/byte-opt.el
test/lisp/emacs-lisp/bytecomp-tests.el

index add13a5c312f2e99c3c4ca1cc328516b3fb8ddfd..f75be3f71ad949bebcba3fe0f004aa5698cf2a12 100644 (file)
@@ -1448,7 +1448,8 @@ See Info node `(elisp) Integer Basics'."
 
 (defun byte-optimize-apply (form)
   (let ((len (length form)))
-    (if (>= len 2)
+    ;; Single-arg `apply' is an abomination that we don't bother optimizing.
+    (if (> len 2)
         (let ((fn (nth 1 form))
              (last (nth (1- len) form)))
           (cond
index 8ccac492141e87d6c294a18f0bf69ee5fc8b03dd..26408e8685ad9a90860e14a142e471e0659177a4 100644 (file)
@@ -800,6 +800,9 @@ inner loops respectively."
     ;; Aristotelian identity optimization
     (let ((x (bytecomp-test-identity 1)))
       (list (eq x x) (eql x x) (equal x x)))
+
+    ;; Legacy single-arg `apply' call
+    (apply '(* 2 3))
     )
   "List of expressions for cross-testing interpreted and compiled code.")