Skip to content
Playground(another site)

bynk.resolve.type_as_function

Error A type name was called as if it were a function.

A type's name is not a function. A refined type is built with .of(value), which checks the value and returns a Result, and a record with a literal such as Order { … }, so Amount(5) has no meaning to fall back on. A sum variant with a payload is the one exception: Placed(at, total) constructs it. A name that is not a type at all is bynk.resolve.unknown_function.

Example

type Amount = Int where NonNegative
fn price() -> Amount {
Amount(5) // ✗ a type is not a function
}
fn price() -> Result[Amount, ValidationError] {
Amount.of(5) // ✓ checked construction
}

In the Book

See also

  • The grammar rule it governs: call.
  • Every code in its category, Resolution, on the diagnostic index.
  • bynk explain bynk.resolve.type_as_function shows the same from the installed toolchain, without a network.