diff options
author | Mattias EngdegÄrd <mattiase@acm.org> | 2023-03-29 13:21:26 +0200 |
---|---|---|
committer | Mattias EngdegÄrd <mattiase@acm.org> | 2023-03-29 19:47:03 +0200 |
commit | 9c31ee468618c95959454736d939eb46bc52b19b (patch) | |
tree | a8ce7a49681f33cb4dabc0e0d60d6bb6a8bd36b9 /test | |
parent | 7177393826c73c87ffe9b428f0e5edae244d7a98 (diff) | |
download | emacs-9c31ee468618c95959454736d939eb46bc52b19b.tar.gz |
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.
Diffstat (limited to 'test')
-rw-r--r-- | test/lisp/emacs-lisp/bytecomp-tests.el | 6 |
1 files changed, 6 insertions, 0 deletions
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 @@ -1462,6 +1462,12 @@ literals (Bug#20852)." "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)) )) |