1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-12-16 09:50:25 +00:00

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.
This commit is contained in:
Mattias Engdegård 2020-11-09 17:11:05 +01:00
parent 5293795806
commit 575b0681d9
2 changed files with 6 additions and 2 deletions

View File

@ -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)))

View File

@ -167,7 +167,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."