[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 72a457e92e 2/2: Warn about calls to `lsh` (bug#56641)
From: |
Mattias Engdegård |
Subject: |
master 72a457e92e 2/2: Warn about calls to `lsh` (bug#56641) |
Date: |
Sat, 23 Jul 2022 06:19:49 -0400 (EDT) |
branch: master
commit 72a457e92e3b13b071b29afa8912a244843d04bc
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>
Warn about calls to `lsh` (bug#56641)
* lisp/subr.el (lsh): Warn when compiled; recommend `ash`.
* etc/NEWS: Add note.
---
etc/NEWS | 6 ++++++
lisp/subr.el | 5 +++++
2 files changed, 11 insertions(+)
diff --git a/etc/NEWS b/etc/NEWS
index 780dbfa51e..a1fea5d6d6 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -3230,6 +3230,12 @@ to preserve the old behavior, apply
'(take N LIST)' returns the first N elements of LIST; 'ntake' does
the same but works by modifying LIST destructively.
+---
+** Calling 'lsh' now elicits a byte-compiler warning.
+'lsh' behaves in somewhat surprising and platform-dependent ways for
+negative arguments and is generally slower than 'ash' which should be
+used instead.
+
* Changes in Emacs 29.1 on Non-Free Operating Systems
diff --git a/lisp/subr.el b/lisp/subr.el
index 510a77dbc8..06da5e2873 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -528,6 +528,11 @@ i.e., subtract 2 * `most-negative-fixnum' from VALUE
before shifting it.
This function is provided for compatibility. In new code, use `ash'
instead."
+ (declare (compiler-macro
+ (lambda (form)
+ (when (byte-compile-warning-enabled-p 'suspicious 'lsh)
+ (byte-compile-warn-x form "avoid `lsh'; use `ash' instead"))
+ form)))
(when (and (< value 0) (< count 0))
(when (< value most-negative-fixnum)
(signal 'args-out-of-range (list value count)))