Skip to content

Problem with duplicate variables #1

Open
@a3nm

Description

@a3nm

There seems to be a problem when there is a disjunction with the same variable name on both sides:

$ echo "aa" | cargo run --release -- -b "(?P<a>.)|(?P<a>.)" 
    Finished release [optimized] target(s) in 0.03s
     Running `target/release/enum-spanner-rs -b '(?P<a>.)|(?P<a>.)'`
thread 'main' panicked at 'Invalid regexp syntax: Parse(Error { kind: GroupNameDuplicate { original: Span(Position(o: 21, l: 1, c: 22), Position(o: 22, l: 1, c: 23)) }, pattern: "(.|\\s)*(?P<match>(?P<a>.)|(?P<a>.))(.|\\s)*", span: Span(Position(o: 30, l: 1, c: 31), Position(o: 31, l: 1, c: 32)) })', src/libcore/result.rs:997:5
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

There is no such problem in the Python implementation:

echo "aababaababa" | ./main.py "(?P<group_a>a+)(?P<group_b>b+)|(?P<group_b>b+)(?P<group_a>a+)"`

It seems that this could be a limitation of the Rust library for regexps? http://getsentry.github.io/rust-sourcemap/regex_syntax/ast/enum.ErrorKind.html#variant.GroupNameDuplicate

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions