Skip to content
Playground(another site)

bynk.resolve.type_in_expr

Error A type name was used where a value is expected.

A type's name stands for a set of values, not for one, so it cannot be used where a value is expected. This is usually a missing constructor. Build a value in the type's own way: Type { … } for a record, a variant name for a sum, Type.of(value) for a refined type. A type used as a call, Type(…), is bynk.resolve.type_as_function.

Example

type Metres = Int where NonNegative
fn grow(x: Int) -> Int { x + Metres } // ✗ `Metres` is a type, not a value
fn grow(x: Int) -> Result[Metres, ValidationError] { Metres.of(x + 1) } // ✓ build a `Metres`

In the Book

See also

  • Every code in its category, Resolution, on the diagnostic index.
  • bynk explain bynk.resolve.type_in_expr shows the same from the installed toolchain, without a network.