This PR adds support for enumerators with associated fields.
This feature is only available in Slice2 mode, and only for enums that don't specify an underlying type.
enum E {
A
B(b: bool)
C(s: Sequence<int32?>, tag(12) s: string)
}
The syntax of associated fields is equivalent to... fields (go figure). Anything supported by fields is supported by these.
Note that I am aware of the TODO in the cycle checking logic. I'm just splitting it off into it's own PR.
Summary of enums
In Slice1, enums cannot specify an underlying type, and enumerators cannot declare associated fields.
Enumerators can declare values that are within the range of 0 and int32::MAX.
If a 'Slice1' enum is used in a Slice2 file, it is treated as-if it has the underlying type int32.
In Slice2, enums can specify an underlying type.
Enums with underlying types cannot use associated fields, but can assign values to it's enumerators.
Enums without underlying types can use associated fields, but cannot assign values to it's enumerators.
This PR adds support for enumerators with associated fields.
This feature is only available in
Slice2
mode, and only for enums that don't specify an underlying type.The syntax of associated fields is equivalent to... fields (go figure). Anything supported by fields is supported by these.
Note that I am aware of the TODO in the cycle checking logic. I'm just splitting it off into it's own PR.
Summary of enums
In
Slice1
, enums cannot specify an underlying type, and enumerators cannot declare associated fields. Enumerators can declare values that are within the range of0
andint32::MAX
. If a 'Slice1' enum is used in aSlice2
file, it is treated as-if it has the underlying typeint32
.In
Slice2
, enums can specify an underlying type. Enums with underlying types cannot use associated fields, but can assign values to it's enumerators. Enums without underlying types can use associated fields, but cannot assign values to it's enumerators.See #30