From 7c63b632e4e2241a28f08015cc981a72e18d7867 Mon Sep 17 00:00:00 2001 From: Mattias EngdegÄrd Date: Thu, 29 Dec 2022 13:01:47 +0100 Subject: 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. --- lisp/emacs-lisp/macroexp.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lisp/emacs-lisp/macroexp.el') diff --git a/lisp/emacs-lisp/macroexp.el b/lisp/emacs-lisp/macroexp.el index 8953e5fd019..8aa9cb860c4 100644 --- a/lisp/emacs-lisp/macroexp.el +++ b/lisp/emacs-lisp/macroexp.el @@ -368,7 +368,7 @@ Assumes the caller has bound `macroexpand-all-environment'." (macroexp-unprogn (macroexp-warn-and-return (format "Empty %s body" fun) - nil nil 'compile-only fun)) + nil (list 'empty-body fun) 'compile-only fun)) (macroexp--all-forms body)) (cdr form)) form))) -- cgit v1.2.3