Skip to content
Playground(another site)

bynk.val.literal_violates

Error A pinned Val[T] value violates the type's refinement.

A pinned Val[T](…) is checked against the refinement of T at compile time, and this literal breaks it, so the test would build a value the type does not allow. Pin a value that satisfies the refinement, or drop the pin and let Val[T] choose one. To test that an invalid value is refused, call T.of(…) and expect an Err.

Example

demo/ages.bynk
type Age = Int where InRange(0, 150)
// tests/ages.test.bynk
let a = Val[Age](200) // ✗ 200 is outside InRange(0, 150)
let a = Val[Age](20) // ✓ inside it

In the Book

See also

  • The grammar rule it governs: val_expr.
  • Every code in its category, Value fabrication, on the diagnostic index.
  • bynk explain bynk.val.literal_violates shows the same from the installed toolchain, without a network.