From 575b0681d926463960fc00d1e33decaa71d5c956 Mon Sep 17 00:00:00 2001
From: Mattias EngdegÄrd <mattiase@acm.org>
Date: Mon, 9 Nov 2020 17:11:05 +0100
Subject: Fix pcase rx form snag with '?' and '??' (bug#44532)

This is a regression from Emacs 26.
Reported by Phillip Stephani.

* lisp/emacs-lisp/rx.el (rx--pcase-transform): Process ? and ?? correctly.
* test/lisp/emacs-lisp/rx-tests.el (rx-pcase): Add test case.
---
 lisp/emacs-lisp/rx.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'lisp/emacs-lisp/rx.el')

diff --git a/lisp/emacs-lisp/rx.el b/lisp/emacs-lisp/rx.el
index 8d8d071031c..76c3ac31b85 100644
--- a/lisp/emacs-lisp/rx.el
+++ b/lisp/emacs-lisp/rx.el
@@ -1413,7 +1413,7 @@ into a plain rx-expression, collecting names into `rx--pcase-vars'."
                 (mapconcat #'symbol-name rx--pcase-vars " ")))
        `(backref ,index)))
     ((and `(,head . ,rest)
-          (guard (and (symbolp head)
+          (guard (and (or (symbolp head) (memq head '(?\s ??)))
                       (not (memq head '(literal regexp regex eval))))))
      (cons head (mapcar #'rx--pcase-transform rest)))
     (_ rx)))
-- 
cgit v1.2.3