From 9c31ee468618c95959454736d939eb46bc52b19b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Engdeg=C3=A5rd?= Date: Wed, 29 Mar 2023 13:21:26 +0200 Subject: Warn about unwind-protect without unwind forms `unwind-protect` without unwind forms is not just pointless but often indicates a mistake where the intended unwind part is misplaced, as in (unwind-protect (progn PROT-FORMS UNWIND-FORMS)) ; oops or (unwind-protect PROT-FORM) UNWIND-FORMS ; also oops or entirely forgotten for that matter. Warning about this makes sense, and the warning can always be silenced by removing the `unwind-protect` altogether if it shouldn't be there in the first place. * lisp/emacs-lisp/macroexp.el (macroexp--expand-all): Implement warning. * etc/NEWS: Announce. * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-test--with-suppressed-warnings): Add test case. --- test/lisp/emacs-lisp/bytecomp-tests.el | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'test/lisp/emacs-lisp') diff --git a/test/lisp/emacs-lisp/bytecomp-tests.el b/test/lisp/emacs-lisp/bytecomp-tests.el index 2cd4dd75742..5bad1ce41a8 100644 --- a/test/lisp/emacs-lisp/bytecomp-tests.el +++ b/test/lisp/emacs-lisp/bytecomp-tests.el @@ -1461,6 +1461,12 @@ literals (Bug#20852)." '((suspicious condition-case)) "Warning: `condition-case' without handlers") + (test-suppression + '(defun zot (x) + (unwind-protect (print x))) + '((suspicious unwind-protect)) + "Warning: `unwind-protect' without unwind forms") + (test-suppression '(defun zot () (let ((_ 1)) -- cgit v1.2.1