Skip to content
Playground(another site)

bynk.record_spread.non_record_base

Error The base of a record spread is not a record.

The base of a spread supplies the fields that are not overridden, so it has to be a value of a record type. An Int, a List or a sum value has no fields to copy. Spread a record, or build the record with every field written out. A base of a different record is bynk.record_spread.type_mismatch.

Example

type Counter = { n: Int }
fn bump(count: Int, c: Counter) -> Counter {
Counter { ...count, n: 1 } // ✗ `count` is an `Int`, not a record
}
fn bump(count: Int, c: Counter) -> Counter {
Counter { ...c, n: count } // ✓ spread the record, override the 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.non_record_base shows the same from the installed toolchain, without a network.