fwcd / swift-binary-coder

Flat, untagged binary serializer for Codable Swift types
https://fwcd.github.io/swift-binary-coder/documentation/binarycoder
MIT License
3 stars 1 forks source link

Investigate how to fix untagged enum serialization #3

Open fwcd opened 2 years ago

fwcd commented 2 years ago

Since the synthesized Encodable implementation for enums is externally tagged by key and we discard keys during encoding, enums currently use a completely untagged representation, which can make it hard to distinguish cases during decoding.

As described in the test case, we should investigate whether non-.untaggedAndAmbiguous strategies should throw an error, even though there may be a runtime cost to detect whether a type is an enum (e.g. through reflection)?