Skip to content

Bug(expr): regex dialect accepts four constructs outside the stated Python/Rust intersection #310

Description

@uberware

Summary

RFC 0006 defines the regex dialect as "the intersection of Python's re module and Rust's
regex crate". Four constructs outside that intersection are accepted:

  • A. \p{Nd} — Unicode property classes (Rust-only; Python re rejects:
    bad escape \p at position 0)
  • B. (?<name>...) — Rust's group-name spelling (Python requires (?P<name>...) and
    rejects this one: unknown extension ?<n at position 1)
  • C. [[:alpha:]] — POSIX classes (in neither engine's shared subset: Python and Go
    both parse it as an ordinary bracket expression that matches "a]" but not "a")
  • D. [a-z--[aeiou]] — Rust's -- set-difference class operator, genuinely
    implemented: re_search('a', r'[a-z--[aeiou]]')null (vowel excluded) while
    re_search('b', ...) matches. Python's re parses the same pattern as ordinary ranges
    (matching "b]", not "b"), so the same template means different things under the two
    readings the spec says must agree.

Versions

  • openjd-model 0.11.1 and 0.11.2 from PyPI
  • openjd-rs main at 1a89f3a — all four still reproduce

Reproduction

from openjd.expr import parse_expression
cases = [
    r"re_search('3', r'\p{Nd}')",         # -> ["3"]         (accepted)
    r"re_search('ab', r'(?<n>a)b')",      # -> ["ab", "a"]   (accepted)
    r"re_search('a', r'[[:alpha:]]')",    # -> ["a"]         (accepted, POSIX reading)
    r"re_search('a', r'[a-z--[aeiou]]')", # -> null          (set difference applied)
    r"re_search('b', r'[a-z--[aeiou]]')", # -> ["b"]         (set difference applied)
]
for src in cases:
    r = parse_expression(src).evaluate_with_metrics()
    print(src, "->", str(r.value))

Each construct was checked against real Python re directly (rejection messages above), not
just against the spec text.

Why this matters

A template written against this implementation can use patterns a spec-conformant
implementation must reject — and for -- and [[:alpha:]], patterns that silently match
differently
in engines that treat them as ordinary bracket expressions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions