bynk.generics.missing_key_bound
Error A type parameter keys a Map or Set (a Map key, a Set element, a distinct/groupBy/join key), or is passed to a Key-bounded parameter of another generic, but is not declared Key ([K: Key], or where A: Key for a receiver type's parameter; on the type for a generic type's own parameter). The diagnostic carries a machine-applicable fix that declares Key, replacing an existing Eq, which Key implies (constrained-generics slice 2).
A Map key or a Set element must be a type that can be held under a canonical encoding, and a type parameter might be a function or another type that cannot. So a type parameter that reaches a Map key or a Set element, in a signature, a generic type's field, or a distinct, groupBy or join key, must be declared K: Key, and a call must instantiate it with a key type. Key implies Eq, so an existing Eq bound is replaced rather than joined (K: Eq + Key is a warning). The diagnostic's fix declares the bound, and bynk check --fix applies it across a project.
Example
fn single[K](k: K) -> Map[K, Int] { // ✗ `K` has no `Key` bound Map.empty().insert(k, 1)}
fn single[K: Key](k: K) -> Map[K, Int] { // ✓ declared Map.empty().insert(k, 1)}In the Book
See also
- The grammar rule it governs:
fn_decl. - Every code in its category, Generics, on the diagnostic index.
bynk explain bynk.generics.missing_key_boundshows the same from the installed toolchain, without a network.