bynk.types.field_default_on_variant
Error A sum variant's payload field declares a default (field: T = expr). Only a record's fields may; a variant is built like a call, with every payload field given.
Only a record's fields take defaults. A variant is built like a call, with every payload field given, so a default on a payload field would be an optional argument by another name. Remove it and give the field wherever the variant is built, or hold the optional values in a record, which can have defaults, and make that record the payload.
Example
type Retry = | Never | Times(n: Int = 3) // ✗ a variant's field has no default
type Backoff = { n: Int = 3 }
type Retry = | Never | Times(opts: Backoff) // ✓ the record carries the defaultIn the Book
See also
- Every code in its category, Type checking, on the diagnostic index.
bynk explain bynk.types.field_default_on_variantshows the same from the installed toolchain, without a network.