Skip to content
Playground(another site)

bynk.types.example_not_literal

Error An @example is not exactly one literal of the base type.

@example takes exactly one literal of the refinement's base type. It is read where the type is declared, not evaluated, so a call such as Code.of("ABC"), a name or a literal of another type is refused. Write the value itself, as a string for a String base.

Example

type Code = String where Matches("[A-Z]{3}") @example(Code.of("ABC")) // ✗ a call, not a literal
type Code = String where Matches("[A-Z]{3}") @example("ABC") // ✓
const Sample: String = "ABC"
type Tag = String where Matches("[A-Z]{3}") @example(Sample) // ✓ a `String` constant bound to a literal

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.example_not_literal shows the same from the installed toolchain, without a network.