Skip to content

Prevent empty negated groups in Rust #68

Open
@Aloso

Description

@Aloso

Describe the bug

Since empty groups such as [] or [^\s\S] are forbidden in Rust, Pomsky tries its best to detect them and show an error. However, this is currently far from comprehensive.

To Reproduce

Try to compile any of these with the regex crate:

  • ![w !d]
  • [!w !s]
  • [!Latin !s]
  • [U+00-U+10FFFF]

There are many more cases, and catching all requires some refactoring.

Expected behavior

This error should also be emitted for the above cases:

error P0307(resolve): 
  × This negated character class matches nothing
   ╭────
 1 │ ![s !s]
   ·  ───┬──
   ·     ╰── error occurred here
   ╰────

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions