summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/pcase.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2021-08-12 11:04:30 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2021-08-12 11:04:30 -0400
commit96d83a854673797952e678796e2165c187a24f54 (patch)
treedc1ab81b1c0f6acda9add3cde33491596399309a /lisp/emacs-lisp/pcase.el
parent0a611a5d7fa4e1186f98a2f98da2d000a87c8b9b (diff)
downloademacs-96d83a854673797952e678796e2165c187a24f54.tar.gz
emacs-96d83a854673797952e678796e2165c187a24f54.tar.bz2
emacs-96d83a854673797952e678796e2165c187a24f54.zip
* lisp/emacs-lisp/pcase.el (pcase-setq): Align its semantics with `pcase-let`
* test/lisp/emacs-lisp/pcase-tests.el (pcase-tests-setq): Rename from pcase-setq and ajust accordingly.
Diffstat (limited to 'lisp/emacs-lisp/pcase.el')
-rw-r--r--lisp/emacs-lisp/pcase.el18
1 files changed, 10 insertions, 8 deletions
diff --git a/lisp/emacs-lisp/pcase.el b/lisp/emacs-lisp/pcase.el
index d111d9e41f8..63b187be02b 100644
--- a/lisp/emacs-lisp/pcase.el
+++ b/lisp/emacs-lisp/pcase.el
@@ -326,7 +326,8 @@ Evaluation happens sequentially as in `setq' (not in parallel).
An example: (pcase-setq `((,a) [(,b)]) '((1) [(2)]))
-When a PATTERN doesn't match it's VALUE, the pair is silently skipped.
+VAL is presumed to match PAT. Failure to match may signal an error or go
+undetected, binding variables to arbitrary values, such as nil.
\(fn PATTERNS VALUE PATTERN VALUES ...)"
(declare (debug (&rest [pcase-PAT form])))
@@ -348,13 +349,14 @@ When a PATTERN doesn't match it's VALUE, the pair is silently skipped.
(t
(pcase-compile-patterns
val
- (list (cons pat
- (lambda (varvals &rest _)
- `(setq ,@(mapcan (lambda (varval)
- (let ((var (car varval))
- (val (cadr varval)))
- (list var val)))
- varvals)))))))))
+ `((,pat
+ . ,(lambda (varvals &rest _)
+ `(setq ,@(mapcan (lambda (varval)
+ (let ((var (car varval))
+ (val (cadr varval)))
+ (list var val)))
+ varvals))))
+ (pcase--dontcare . ignore))))))
(defun pcase--trivial-upat-p (upat)
(and (symbolp upat) (not (memq upat pcase--dontcare-upats))))