summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/pcase.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2014-09-27 00:24:06 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2014-09-27 00:24:06 -0400
commit528872c5f87d0edb38befe96a5eb0ab3f27db76d (patch)
tree22ee81f779789c4e9caf6264355fd8d778fe37b5 /lisp/emacs-lisp/pcase.el
parente6cfa098ae23e34c5415642e2f848a92982924ef (diff)
downloademacs-528872c5f87d0edb38befe96a5eb0ab3f27db76d.tar.gz
emacs-528872c5f87d0edb38befe96a5eb0ab3f27db76d.tar.bz2
emacs-528872c5f87d0edb38befe96a5eb0ab3f27db76d.zip
* lisp/emacs-lisp/pcase.el (pcase--split-match, pcase--app-subst-match):
Handle the case where `match' is :pcase--succeed or :pcase--fail. Fixes: debbugs:18554
Diffstat (limited to 'lisp/emacs-lisp/pcase.el')
-rw-r--r--lisp/emacs-lisp/pcase.el10
1 files changed, 6 insertions, 4 deletions
diff --git a/lisp/emacs-lisp/pcase.el b/lisp/emacs-lisp/pcase.el
index ddcd4040f2b..753cd3005e6 100644
--- a/lisp/emacs-lisp/pcase.el
+++ b/lisp/emacs-lisp/pcase.el
@@ -435,12 +435,12 @@ MATCH is the pattern that needs to be matched, of the form:
(defun pcase--split-match (sym splitter match)
(cond
- ((eq (car match) 'match)
+ ((eq (car-safe match) 'match)
(if (not (eq sym (cadr match)))
(cons match match)
(let ((res (funcall splitter (cddr match))))
(cons (or (car res) match) (or (cdr res) match)))))
- ((memq (car match) '(or and))
+ ((memq (car-safe match) '(or and))
(let ((then-alts '())
(else-alts '())
(neutral-elem (if (eq 'or (car match))
@@ -460,6 +460,7 @@ MATCH is the pattern that needs to be matched, of the form:
((null else-alts) neutral-elem)
((null (cdr else-alts)) (car else-alts))
(t (cons (car match) (nreverse else-alts)))))))
+ ((memq match '(:pcase--succeed :pcase--fail)) (cons match match))
(t (error "Uknown MATCH %s" match))))
(defun pcase--split-rest (sym splitter rest)
@@ -570,17 +571,18 @@ MATCH is the pattern that needs to be matched, of the form:
(defun pcase--app-subst-match (match sym fun nsym)
(cond
- ((eq (car match) 'match)
+ ((eq (car-safe match) 'match)
(if (and (eq sym (cadr match))
(eq 'app (car-safe (cddr match)))
(equal fun (nth 1 (cddr match))))
(pcase--match nsym (nth 2 (cddr match)))
match))
- ((memq (car match) '(or and))
+ ((memq (car-safe match) '(or and))
`(,(car match)
,@(mapcar (lambda (match)
(pcase--app-subst-match match sym fun nsym))
(cdr match))))
+ ((memq match '(:pcase--succeed :pcase--fail)) match)
(t (error "Uknown MATCH %s" match))))
(defun pcase--app-subst-rest (rest sym fun nsym)