GNU bug report logs - #34641
rx: (or ...) order unpredictable

Previous Next

Package: emacs;

Reported by: Mattias Engdegård <mattiase <at> acm.org>

Date: Sun, 24 Feb 2019 18:41:02 UTC

Severity: normal

Done: Mattias Engdegård <mattiase <at> acm.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Noam Postavsky <npostavs <at> gmail.com>
To: Mattias Engdegård <mattiase <at> acm.org>
Cc: 34641 <at> debbugs.gnu.org
Subject: bug#34641: rx: (or ...) order unpredictable
Date: Sun, 24 Feb 2019 21:37:56 -0500
On Sun, 24 Feb 2019 at 13:41, Mattias Engdegård <mattiase <at> acm.org> wrote:
>
> The rx (or ...) construct sometimes reorders its subexpressions, which makes its semantics unpredictable. For example,
>
> (rx (or "ab" "a") (or "a" "ab"))
> =>
> "\\(?:ab?\\)\\(?:ab?\\)"
>
> The user reasonably expects (or e1 e2) to translate to E1\|E2, where ei translates to Ei, or a semantic equivalent.

I don't see the problem, isn't "ab?" semantically equivalent to
"ab\\|a" (and "a\\|ab")?

> (Speaking of regexp-opt, it has another bug that does not affect rx: it returns the empty string if given an empty list of strings. The correct return value is a regexp that never matches anything.

This sounds familiar, though I can't locate a report for it.




This bug report was last modified 6 years and 72 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.