bynk.types.polynomial_regex
Error A Matches pattern can split the same text between repetitions, so matching time grows polynomially with input length, and no length predicate bounds the input small enough for its degree; a regex method's pattern has no bound to excuse it.
A Matches pattern runs under a backtracking RegExp on untrusted input. Two repetitions in sequence that can match the same characters, as in \d*\d*, let the engine split a run between them many ways, so the time grows as a power of the input's length. That is slower to hurt than bynk.types.catastrophic_regex but can still stall a handler. A MaxLength, Length or IsoDate predicate that keeps the input short enough makes it the warning bynk.types.polynomial_regex_capped; a regex method has no such bound. Rewrite it so the repetitions cannot overlap.
Example
type Digits = String where Matches("\\d*\\d*") // ✗ two loops over the same digits
type Digits = String where Matches("\\d*") // ✓ one way to matchIn 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.polynomial_regexshows the same from the installed toolchain, without a network.