This adds support for enums with negative discriminants and slightly improves error messages.
Honestly, implementing this was pretty simple. I don't have too much to say about this, just a few notes on implementation details:
Within the serialized data for ASTs and descriptors, variants are still passed around as u32. Instead of representing the actual value, they now represent the bits of the i32 or u32 value. Which one it is depends on the new signed: bool field. I wanted to use i64, but this doesn't work well with inform or other serialization, so I opted to "decode" the variant values to i64 on the CLI side just before JS code gen.
Holes. The parser will only search for non-negative holes. This means that a signed enum with 2^31 variants will fail to find a hole, but I think that's okay. Not having to worry about the sign of a hole also makes the downstream code handling holes simpler.
fixes #2313
This adds support for enums with negative discriminants and slightly improves error messages.
Honestly, implementing this was pretty simple. I don't have too much to say about this, just a few notes on implementation details:
u32
. Instead of representing the actual value, they now represent the bits of thei32
oru32
value. Which one it is depends on the newsigned: bool
field. I wanted to usei64
, but this doesn't work well withinform
or other serialization, so I opted to "decode" the variant values to i64 on the CLI side just before JS code gen.