SE-0295: Codable synthesis for enums with associated values

I think that makes sense and should be straightforward to implement.

The plain value would indeed be problematic. Not necessarily because of top-level values, because those are actually allowed since RFC-8259. The bigger problem is that Decoder does not define functions to check for this. We have to know upfront whether we have a KeyedContainer, UnkeyedContainer, or SingleValueContainer. Adding the required functionality would break ABI.

Another alternative would be to use null as the value, i.e.

{
  "dumpToDisk": null
}

This is unbiased and not less confusing than a boolean value.

I think this makes sense. I slightly prefer the last version, because that still has the CodingKeys part in it, which is less likely to to collide with user defined names.

4 Likes