Skip to content

Surprising precedence when stringifying concatenations of alternations #516

Closed
@exists-forall

Description

@exists-forall

In the hir module of the regex-syntax crate, concatenating onto an alternation and calling to_string on the resulting concatenation currently produces a pattern string where the concatenation binds more tightly than the alternation. This is most easily understood with an example: https://play.rust-lang.org/?gist=36767c381c97f169e219c8c707c001ad&version=stable&mode=debug&edition=2015

I don't know if this current behavior is intended or not, but I originally expected that the pattern string printed in the example above would look something like A(?:B|C), not AB|C, as the concatenation is logically the root of the HIR tree. Would it be possible to at least document this behavior?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions