Skip to content
Playground(another site)

bynk.parse.keyword_field_shorthand

Error A reserved keyword was used as a field shorthand, which would bind a variable of that name.

A record pattern or construction may write a field by name alone ({ total }), which binds a variable of that name. A reserved word cannot be a variable, so { type, .. } is refused, though type is allowed as a field label before a :. In a pattern, name the binding: type: type_; the compiler offers that fix. In a construction, give the value: type: "Org".

Example

match a {
Account { type, .. } => type // ✗ shorthand binds a keyword
Account { type: type_, .. } => type_ // ✓ name the binding
}

In the Book

See also

  • The grammar rule it governs: identifier.
  • Every code in its category, Parser, on the diagnostic index.
  • bynk explain bynk.parse.keyword_field_shorthand shows the same from the installed toolchain, without a network.