On this page

0086. Binary map keys match supported scalar codecs

Context

Binary encodes map keys as typed values, unlike JSON's string keys. Validating keys as arbitrary codec values permits vectors and records through generation, then fails type-checking the generated map helpers. Paths are valid kernel map keys but have no Binary codec.

Decision

Binary map keys are integers, bool, str, bytes and newtypes recursively wrapping these types. Named keys still require their own Binary derives. Reject other keys with a field-path E0966 before emitting a companion. This narrows validation to the intersection of kernel map keys and implemented Binary codecs; it adds no wire format or compiler/runtime support.

Alternatives considered

Consequences

Unsupported schemas fail at the derive with one stable generator diagnostic. Tests pin rejected key categories and roundtrip all accepted scalar categories both directly and through nested newtypes on C and the interpreter.