Skip to content
Playground(another site)

bynk.record_spread.unknown_field

Error A record spread overrides a field the record does not have.

A record spread, T { ...base, field: value }, copies every field of base and replaces the ones you list. Each listed field has to be one the record declares: a misspelt or invented name would otherwise be dropped silently, or build a value that is not a T. Check the field name against the type's declaration. To add a field, declare it on the type first.

Example

type Counter = { n: Int }
fn bump(c: Counter) -> Counter {
Counter { ...c, missing: 0 } // ✗ `Counter` has no field `missing`
}
fn bump(c: Counter) -> Counter {
Counter { ...c, n: 0 } // ✓ an existing field
}

In the Book

See also

  • The grammar rule it governs: record_spread.
  • Every code in its category, Record spread, on the diagnostic index.
  • bynk explain bynk.record_spread.unknown_field shows the same from the installed toolchain, without a network.