Skip to content
Playground(another site)

bynk.val.pin_not_literal

Error A Val[T] pin argument is not a compile-time literal.

A pin on Val[T] is checked against the refinement of T when the program compiles, so it must be a literal of T's base type. A name or a call has no value at that point. Write the literal in place. For a computed value, build it with Age.of(…) and ?, which fails the case if the value is not valid.

Example

demo/ages.bynk
type Age = Int where InRange(0, 150)
// tests/ages.test.bynk
let n = 20
let a = Val[Age](n) // ✗ a name, not a literal
let a = Val[Age](20) // ✓ a literal

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