summaryrefslogtreecommitdiff
path: root/test/lisp/emacs-lisp/pcase-tests.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2021-03-01 15:35:51 -0500
committerStefan Monnier <monnier@iro.umontreal.ca>2021-03-01 15:35:51 -0500
commit0d827c7f52b92aaffe751cf937427938f1ac67de (patch)
treef7c953e30ace16514c9aedcee63441e09764521d /test/lisp/emacs-lisp/pcase-tests.el
parent08b11a02f49da5ca0e4e58a32fa853df0c5e0214 (diff)
downloademacs-0d827c7f52b92aaffe751cf937427938f1ac67de.tar.gz
* lisp/emacs-lisp/pcase.el: Fix bug#46786
Revert commit a218c9861573b5ec4979ff2662f5c0343397e3ff, but in order to avoid the spurious warnings that this commit tried to squash, keep track of the vars used during the match so as to add corresponding annotations to explicitly silence the spurious warnings. To do this, we change the VARS used in `pcase-u` (and throughout the pcase code): they used to hold elements of the form (NAME . VAL) and now they hold elements of the form (NAME VAL . USED). (pcase--expand): Bind all vars instead of only those found via fgrep. (pcase-codegen): Silence "unused var" warnings for those vars that have already been referenced during the match itself. (pcase--funcall, pcase--eval): Record the vars that are used. (pcase--u1): Record the vars that are used via non-linear patterns. * lisp/textmodes/mhtml-mode.el (mhtml-forward): * lisp/vc/diff-mode.el (diff-goto-source): Silence newly discovered warnings. * test/lisp/emacs-lisp/pcase-tests.el (pcase-tests-bug46786): New test.
Diffstat (limited to 'test/lisp/emacs-lisp/pcase-tests.el')
-rw-r--r--test/lisp/emacs-lisp/pcase-tests.el7
1 files changed, 7 insertions, 0 deletions
diff --git a/test/lisp/emacs-lisp/pcase-tests.el b/test/lisp/emacs-lisp/pcase-tests.el
index 14384112b34..6ddeb7b622b 100644
--- a/test/lisp/emacs-lisp/pcase-tests.el
+++ b/test/lisp/emacs-lisp/pcase-tests.el
@@ -83,6 +83,13 @@
(should (equal (funcall f t) 'left))
(should (equal (funcall f nil) 'right))))
+(ert-deftest pcase-tests-bug46786 ()
+ (let ((self 'outer))
+ (should (equal (cl-macrolet ((show-self () `(list 'self self)))
+ (pcase-let ((`(,self ,self2) '(inner "2")))
+ (show-self)))
+ '(self inner)))))
+
;; Local Variables:
;; no-byte-compile: t
;; End: