emacs-diffs
[Top][All Lists]
Advanced

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

emacs-27 1814c7e: Fix rx error with ? and ??


From: Mattias Engdegård
Subject: emacs-27 1814c7e: Fix rx error with ? and ??
Date: Thu, 5 Mar 2020 07:02:23 -0500 (EST)

branch: emacs-27
commit 1814c7e158685045278f991de5eba4e40e8c8199
Author: Mattias Engdegård <address@hidden>
Commit: Mattias Engdegård <address@hidden>

    Fix rx error with ? and ??
    
    The ? and ?? rx operators are special in that they can be written as
    characters (space and '?' respectively).  This confused the definition
    look-up mechanism in rare cases.
    
    * lisp/emacs-lisp/rx.el (rx--expand-def): Don't look up non-symbols.
    * test/lisp/emacs-lisp/rx-tests.el (rx-charset-or): Test.
---
 lisp/emacs-lisp/rx.el            | 2 +-
 test/lisp/emacs-lisp/rx-tests.el | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/lisp/emacs-lisp/rx.el b/lisp/emacs-lisp/rx.el
index d4a9171..aa4b2ad 100644
--- a/lisp/emacs-lisp/rx.el
+++ b/lisp/emacs-lisp/rx.el
@@ -134,7 +134,7 @@ Each entry is:
                 (if (cdr def)
                     (error "Not an `rx' symbol definition: %s" form)
                   (car def)))))
-        ((consp form)
+        ((and (consp form) (symbolp (car form)))
          (let* ((op (car form))
                 (def (rx--lookup-def op)))
            (and def
diff --git a/test/lisp/emacs-lisp/rx-tests.el b/test/lisp/emacs-lisp/rx-tests.el
index 4888e1d..0fece40 100644
--- a/test/lisp/emacs-lisp/rx-tests.el
+++ b/test/lisp/emacs-lisp/rx-tests.el
@@ -316,7 +316,9 @@
   (should (equal (rx (not (or (in "abc") (char "bcd"))))
                  "[^a-d]"))
   (should (equal (rx (or (not (in "abc")) (not (char "bcd"))))
-                 "[^bc]")))
+                 "[^bc]"))
+  (should (equal (rx (or "x" (? "yz")))
+                 "x\\|\\(?:yz\\)?")))
 
 (ert-deftest rx-def-in-charset-or ()
   (rx-let ((a (any "badc"))



reply via email to

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