Function: pcase-exhaustive

pcase-exhaustive is an autoloaded macro defined in pcase.el.gz.

Signature

(pcase-exhaustive EXP &rest CASES)

Documentation

The exhaustive version of pcase (which see).

If EXP fails to match any of the patterns in CASES, an error is signaled.

In contrast, pcase will return nil if there is no match, but not signal an error.

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/pcase.el.gz
;;;###autoload
(defmacro pcase-exhaustive (exp &rest cases)
  "The exhaustive version of `pcase' (which see).
If EXP fails to match any of the patterns in CASES, an error is
signaled.

In contrast, `pcase' will return nil if there is no match, but
not signal an error."
  (declare (indent 1) (debug pcase))
  (let* ((x (gensym "x"))
         (pcase--dontwarn-upats (cons x pcase--dontwarn-upats)))
    (pcase--expand
     ;; FIXME: Could we add the FILE:LINE data in the error message?
     ;; FILE is available from `macroexp-file-name'.
     exp (append cases `((,x (error "No clause matching `%S'" ,x)))))))