mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-17 03:10:58 -08: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.
(cherry picked from commit 575b0681d9)
This commit is contained in:
parent
75384bd155
commit
78e1646bf7
2 changed files with 6 additions and 2 deletions
|
|
@ -1413,7 +1413,7 @@ into a plain rx-expression, collecting names into `rx--pcase-vars'."
|
||||||
(mapconcat #'symbol-name rx--pcase-vars " ")))
|
(mapconcat #'symbol-name rx--pcase-vars " ")))
|
||||||
`(backref ,index)))
|
`(backref ,index)))
|
||||||
((and `(,head . ,rest)
|
((and `(,head . ,rest)
|
||||||
(guard (and (symbolp head)
|
(guard (and (or (symbolp head) (memq head '(?\s ??)))
|
||||||
(not (memq head '(literal regexp regex eval))))))
|
(not (memq head '(literal regexp regex eval))))))
|
||||||
(cons head (mapcar #'rx--pcase-transform rest)))
|
(cons head (mapcar #'rx--pcase-transform rest)))
|
||||||
(_ rx)))
|
(_ rx)))
|
||||||
|
|
|
||||||
|
|
@ -158,7 +158,11 @@
|
||||||
(let ((k "blue"))
|
(let ((k "blue"))
|
||||||
(should (equal (pcase "<blue>"
|
(should (equal (pcase "<blue>"
|
||||||
((rx "<" (literal k) ">") 'ok))
|
((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 ()
|
(ert-deftest rx-kleene ()
|
||||||
"Test greedy and non-greedy repetition operators."
|
"Test greedy and non-greedy repetition operators."
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue