emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

emacs-27 78e1646: Fix pcase rx form snag with '?' and '??' (bug#44532)


From: Eli Zaretskii
Subject: emacs-27 78e1646: Fix pcase rx form snag with '?' and '??' (bug#44532)
Date: Mon, 9 Nov 2020 12:00:53 -0500 (EST)

branch: emacs-27
commit 78e1646bf7bde8f00c196319f4803e98460d506a
Author: Mattias EngdegÄrd <mattiase@acm.org>
Commit: Eli Zaretskii <eliz@gnu.org>

    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.
    
    (cherry picked from commit 575b0681d926463960fc00d1e33decaa71d5c956)
---
 lisp/emacs-lisp/rx.el            | 2 +-
 test/lisp/emacs-lisp/rx-tests.el | 6 +++++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/lisp/emacs-lisp/rx.el b/lisp/emacs-lisp/rx.el
index 6564563..88c843f 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)))
diff --git a/test/lisp/emacs-lisp/rx-tests.el b/test/lisp/emacs-lisp/rx-tests.el
index 0fece40..05779b4 100644
--- a/test/lisp/emacs-lisp/rx-tests.el
+++ b/test/lisp/emacs-lisp/rx-tests.el
@@ -158,7 +158,11 @@
   (let ((k "blue"))
     (should (equal (pcase "<blue>"
                      ((rx "<" (literal k) ">") 'ok))
-                   'ok))))
+                   'ok)))
+  (should (equal (pcase "abc"
+                   ((rx (? (let x alpha)) (?? (let y alnum)) ?c)
+                    (list x y)))
+                 '("a" "b"))))
 
 (ert-deftest rx-kleene ()
   "Test greedy and non-greedy repetition operators."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]