[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 9f856e4cd09 1/2: Use `mutate-constant` as warning identifier
From: |
Mattias Engdegård |
Subject: |
master 9f856e4cd09 1/2: Use `mutate-constant` as warning identifier |
Date: |
Sat, 13 May 2023 08:44:47 -0400 (EDT) |
branch: master
commit 9f856e4cd095c24cf4e6cadbc04efaf533e59f37
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>
Use `mutate-constant` as warning identifier
* etc/NEWS:
* lisp/emacs-lisp/byte-run.el (with-suppressed-warnings):
* lisp/emacs-lisp/bytecomp.el (byte-compile-warnings)
(byte-compile-form):
* test/lisp/emacs-lisp/bytecomp-tests.el
(bytecomp-test--with-suppressed-warnings):
Use the new warning name `mutate-constant` instead of using the
somewhat overloaded `suspicious`.
---
etc/NEWS | 2 +-
lisp/emacs-lisp/byte-run.el | 2 +-
lisp/emacs-lisp/bytecomp.el | 4 +++-
test/lisp/emacs-lisp/bytecomp-tests.el | 10 +++++-----
4 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/etc/NEWS b/etc/NEWS
index 7d033b0b13e..b4846eb11b0 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -527,7 +527,7 @@ To avoid the warning, operate on an object created by the
program
instead.
This warning can be suppressed using 'with-suppressed-warnings' with
-the warning name 'suspicious'.
+the warning name 'mutate-constant'.
---
*** Warn about more ignored function return values.
diff --git a/lisp/emacs-lisp/byte-run.el b/lisp/emacs-lisp/byte-run.el
index 5b415c5e1f4..a377ec395e1 100644
--- a/lisp/emacs-lisp/byte-run.el
+++ b/lisp/emacs-lisp/byte-run.el
@@ -658,7 +658,7 @@ in `byte-compile-warning-types'; see the variable
types. The types that can be suppressed with this macro are
`free-vars', `callargs', `redefine', `obsolete',
`interactive-only', `lexical', `ignored-return-value', `constants',
-`suspicious' and `empty-body'."
+`suspicious', `empty-body' and `mutate-constant'."
;; Note: during compilation, this definition is overridden by the one in
;; byte-compile-initial-macro-environment.
(declare (debug (sexp body)) (indent 1))
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index d17f1c93a76..a192d599d1d 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -330,6 +330,8 @@ Elements of the list may be:
This depends on the `docstrings' warning type.
suspicious constructs that usually don't do what the coder wanted.
empty-body body argument to a special form or macro is empty.
+ mutate-constant
+ code that mutates program constants such as quoted lists
If the list begins with `not', then the remaining elements specify warnings to
suppress. For example, (not free-vars) will suppress the `free-vars' warning.
@@ -3498,7 +3500,7 @@ lambda-expression."
(consp (nth 1 arg)))
(arrayp arg))
(byte-compile-warning-enabled-p
- 'suspicious (car form)))
+ 'mutate-constant (car form)))
(byte-compile-warn-x form "`%s' on constant %s (arg %d)"
(car form)
(if (consp arg) "list" (type-of arg))
diff --git a/test/lisp/emacs-lisp/bytecomp-tests.el
b/test/lisp/emacs-lisp/bytecomp-tests.el
index 9136a6cd9b3..a8809bda81c 100644
--- a/test/lisp/emacs-lisp/bytecomp-tests.el
+++ b/test/lisp/emacs-lisp/bytecomp-tests.el
@@ -1522,31 +1522,31 @@ literals (Bug#20852)."
(test-suppression
'(defun zot ()
(setcar '(1 2) 3))
- '((suspicious setcar))
+ '((mutate-constant setcar))
"Warning: `setcar' on constant list (arg 1)")
(test-suppression
'(defun zot ()
(aset [1 2] 1 3))
- '((suspicious aset))
+ '((mutate-constant aset))
"Warning: `aset' on constant vector (arg 1)")
(test-suppression
'(defun zot ()
(aset "abc" 1 ?d))
- '((suspicious aset))
+ '((mutate-constant aset))
"Warning: `aset' on constant string (arg 1)")
(test-suppression
'(defun zot (x y)
(nconc x y '(1 2) '(3 4)))
- '((suspicious nconc))
+ '((mutate-constant nconc))
"Warning: `nconc' on constant list (arg 3)")
(test-suppression
'(defun zot ()
(put-text-property 0 2 'prop 'val "abc"))
- '((suspicious put-text-property))
+ '((mutate-constant put-text-property))
"Warning: `put-text-property' on constant string (arg 5)")
)