mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-10 08:10:21 -08:00
Add empty-body warning for when, unless etc
Warn about code like (when SOME-CONDITION) because these may indicate bugs. Warnings currently apply to `when`, `unless`, `ignore-error`, `with-suppressed-warnings` and (as before) `let` and `let*`. * lisp/emacs-lisp/byte-run.el (with-suppressed-warnings): Update doc string. * lisp/emacs-lisp/bytecomp.el: (byte-compile-warning-types) (byte-compile-warnings): Add empty-body. (byte-compile-initial-macro-environment): Add empty-body warning for with-suppressed-warnings. * lisp/emacs-lisp/macroexp.el (macroexp--expand-all): Use the empty-body category for let and let*. * lisp/subr.el (when, unless, ignore-error): Add empty-body warning. * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-test--with-suppressed-warnings): Add test cases.
This commit is contained in:
parent
2de25accaf
commit
7c63b632e4
5 changed files with 84 additions and 24 deletions
|
|
@ -1433,7 +1433,50 @@ literals (Bug#20852)."
|
|||
(set-buffer (get-buffer-create "foo"))
|
||||
nil))
|
||||
'((suspicious set-buffer))
|
||||
"Warning: Use .with-current-buffer. rather than"))
|
||||
"Warning: Use .with-current-buffer. rather than")
|
||||
|
||||
(test-suppression
|
||||
'(defun zot ()
|
||||
(let ((_ 1))
|
||||
))
|
||||
'((empty-body let))
|
||||
"Warning: Empty let body")
|
||||
|
||||
(test-suppression
|
||||
'(defun zot ()
|
||||
(let* ((_ 1))
|
||||
))
|
||||
'((empty-body let*))
|
||||
"Warning: Empty let\\* body")
|
||||
|
||||
(test-suppression
|
||||
'(defun zot (x)
|
||||
(when x
|
||||
))
|
||||
'((empty-body when))
|
||||
"Warning: `when' with empty body")
|
||||
|
||||
(test-suppression
|
||||
'(defun zot (x)
|
||||
(unless x
|
||||
))
|
||||
'((empty-body unless))
|
||||
"Warning: `unless' with empty body")
|
||||
|
||||
(test-suppression
|
||||
'(defun zot (x)
|
||||
(ignore-error arith-error
|
||||
))
|
||||
'((empty-body ignore-error))
|
||||
"Warning: `ignore-error' with empty body")
|
||||
|
||||
(test-suppression
|
||||
'(defun zot (x)
|
||||
(with-suppressed-warnings ((suspicious eq))
|
||||
))
|
||||
'((empty-body with-suppressed-warnings))
|
||||
"Warning: `with-suppressed-warnings' with empty body")
|
||||
)
|
||||
|
||||
(ert-deftest bytecomp-tests--not-writable-directory ()
|
||||
"Test that byte compilation works if the output directory isn't
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue