Implement new enums syntax (enforced underlying type, doc / doc-ref support)#335
Implement new enums syntax (enforced underlying type, doc / doc-ref support)#335generalmimon wants to merge 9 commits intomasterfrom
enums syntax (enforced underlying type, doc / doc-ref support)#335Conversation
See kaitai-io/kaitai_struct#1288 This commit fixes only the tests that were broken compared to the `master` branch when running `sbt test` in a compiler that requires the new syntax for enum definitions: kaitai-io/kaitai_struct_compiler#335
Example error message:
```
formats/enum_values_out_of_type_range_s2.ksy: /enums/animal/values/-32769:
error: integer constant -32769 is out of range -32768..32767 of the enum's underlying type `s2`
```
It was recognized that allowing enums to be applied only to integer types that match the enum's underlying type is unnecessarily restrictive and serves no practical purpose - see kaitai-io/kaitai_struct#1288 (comment)
0614e98 to
23bfab8
Compare
See kaitai-io/kaitai_struct#1288 This commit fixes only the tests that were broken compared to the `master` branch when running `sbt test` in a compiler that requires the new syntax for enum definitions: kaitai-io/kaitai_struct_compiler#335
See kaitai-io/kaitai_struct#1288 Closes #248 (in Go, we no longer use the `int` type with platform-dependent width) Fixes kaitai-io/kaitai_struct#862 Fixes kaitai-io/kaitai_struct#92
See kaitai-io/kaitai_struct#959 As mentioned in the linked issue, this is only possible in C++11 (in C++98, it would be invalid syntax). This means that the undefined behavior still remains in the C++98 code, and therefore kaitai-io/kaitai_struct#959 hasn't been fully resolved yet.
|
Let me summarize the results of this PR. The syntax changes and semantics are explained in kaitai-io/kaitai_struct#1288, so I won't repeat them here. Instead, I will focus on the observable changes in the generated code. Summary
Changes in test resultsC++11 -
|
|
I believe this PR is finished and ready for review - I don't think there is anything left to change before merging. However, I will keep it in the "draft" state, because I don't know yet whether we'll want to merge it into To be honest, I've never had to work with multiple release branches. I suppose there will be something like |
Resolves kaitai-io/kaitai_struct#1288, resolves kaitai-io/kaitai_struct#358
Related PR in the KST repo to update the test suite accordingly: kaitai-io/kaitai_struct_tests#140
As explained in kaitai-io/kaitai_struct#1288, this is a breaking change: the current
enumssyntax is declared old and unsupported ("legacy pre-v0.12 enum syntax"), and only the new syntax is accepted.I can imagine that this will have a big impact, because suddenly almost everyone will have to update their .ksy specs. I suppose it would be possible to maintain support for the old syntax somehow, but that would significantly limit adoption of the new one... So I'm not sure if that's really what we want.