Skip to content
Playground(another site)

bynk.types.invalid_regex

Error A Matches predicate, or a regex method's pattern (containsRegex, …), contains an invalid regular expression or malformed inline flags.

A Matches pattern, and the pattern of a regex method such as containsRegex, must be a valid regular expression. The emitted check runs it under JavaScript's RegExp, so the compiler validates it with those rules: a pattern the Rust regex crate accepts, such as (?P<name>…), may be refused here, and the compiler would otherwise ship a check that throws at run time. A regex method's pattern may open with one inline-flag group of i, m and s, each at most once. Fix the syntax; the note carries the parser's message. A valid but dangerous pattern is bynk.types.catastrophic_regex.

Example

type Code = String where Matches("[A-Z") // ✗ the class is never closed
type Code = String where Matches("[A-Z]+") // ✓

In the Book

See also

  • The grammar rule it governs: refinement.
  • Every code in its category, Type checking, on the diagnostic index.
  • bynk explain bynk.types.invalid_regex shows the same from the installed toolchain, without a network.