You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's a compile-time error if a class or mixin declaration has Enum as a superinterface and the interface of the declarations contains an instance member with the name values, whether declared or inherited. If any concrete class implements this interface, it will be an enum declaration class, and then the values member would conflict with the static values constant getter that is automatically added to enum declaration classes. Such an instance values declaration is either useless or wrong, so we disallow it entirely.
Now there is no expected error in CFE in the folllowing cases
It is clearly said in the specification '... class or mixin declaration has Enum as a superinterface and the interface of the declarations contains an instance member with the name values ...'. So, I believe, CFE should report a compile-time error like analyzer does.
sgrekhov
changed the title
[Enhanced enums] no error in CFE on class/mixin which nas Enum as a superclass and declares values
[Enhanced enums] no error in CFE on class/mixin which has Enum as a superclass and declares valuesFeb 14, 2022
Right, we should have these errors after all. We actually have two different paragraphs about this topic:
It's a compile-time error if the enum declaration contains a static or instance
member declaration with the name values, or if the superclass or
any superinterface of the enum declaration has an interface member named values.
which occurs just before section 'Semantics', and the paragraph that you mentioned:
It's a compile-time error if a class or mixin declaration has Enum as a superinterface
and the interface of the declarations contains an instance member with the name values, whether declared or inherited.
I saw the first one, but overlooked the second one.
The first one is concerned with errors that are reported during the static analysis of an enum declaration, and it catches both instance and static declarations in the enum declaration, and instance declarations in any superinterface. The second one applies to any class/mixin declaration that has Enum as a superinterface, and it only catches instance declarations.
So we can have a static values in any superinterface of an enum (including the mixins mentioned in this issue) without errors. An instance member named values can occur in a mixin/class A without error as long as A does not have Enum as a superinterface, but if A is used as a superinterface of an enum then that enum gets an error.
According to the Enhanced Enums specification
Now there is no expected error in CFE in the folllowing cases
It is clearly said in the specification '... class or mixin declaration has Enum as a superinterface and the interface of the declarations contains an instance member with the name values ...'. So, I believe, CFE should report a compile-time error like analyzer does.
cc @eernstg to confirm
The text was updated successfully, but these errors were encountered: