Closed pepone closed 1 year ago
I see also a number of other issues with this message:
Cleaned-up version
error E011: invalid enum 'MyEnum': underlying type 'None' is not supported for enums
error E011: file is using the Slice2 encoding by default
error E011: to use a different encoding, specify it at the top of the slice file
error E011: ex: 'encoding = Slice1'
error E011: try adding a backing type to your enum: 'enum MyEnum: varint32'
uint8
as the underlying type: 99.9% of the time, that's what you wantAnd the main gist of the message seems to be "are you sure you didn't mean to add encoding = Slice1?", which I find misleading.
As Jose pointed out, I think it makes more sense to focus on the missing underlying type and not Slice encoding of the file.
How about this @pepone @bernardnormier :
error [E011]: invalid enum 'Bar': underlying type 'None' is not supported for enums
--> foo.slice:3:1
|
3 | enum Bar {
| --------
|
= note: Slice2 enums must have an underlying type. e.g. 'enum Bar : uint8'
= note: file is using the Slice2 encoding by default
= note: to use a different encoding, specify it at the top of the slice file. e.g. 'encoding = Slice1
Failed: Compilation failed with 1 error(s)
If you forget to add define the underlying type for an Slice2 enum you get an error like:
I think it would be clear to have a custom message here telling the underlying type is required