[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master b9e8474a447 3/4: Repair miscompilation of single-arg `apply` (bug
From: |
Mattias Engdegård |
Subject: |
master b9e8474a447 3/4: Repair miscompilation of single-arg `apply` (bug#69533) |
Date: |
Mon, 4 Mar 2024 08:21:57 -0500 (EST) |
branch: master
commit b9e8474a4470f71c30a4b89651fd3c5f2ef92ba2
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>
Repair miscompilation of single-arg `apply` (bug#69533)
* 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.
---
lisp/emacs-lisp/byte-opt.el | 3 ++-
test/lisp/emacs-lisp/bytecomp-tests.el | 3 +++
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el
index add13a5c312..f75be3f71ad 100644
--- a/lisp/emacs-lisp/byte-opt.el
+++ b/lisp/emacs-lisp/byte-opt.el
@@ -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
diff --git a/test/lisp/emacs-lisp/bytecomp-tests.el
b/test/lisp/emacs-lisp/bytecomp-tests.el
index 8ccac492141..26408e8685a 100644
--- a/test/lisp/emacs-lisp/bytecomp-tests.el
+++ b/test/lisp/emacs-lisp/bytecomp-tests.el
@@ -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.")