-
Notifications
You must be signed in to change notification settings - Fork 1.1k
consider making "Enumerations must contain at least one case" a warning #16375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I don't think there's any technical reason not to, I can trace the original check being added to #5015, so potentially there may be a repl issue. this would not require a formal grammar change either. Edit: One potential problem is that previously all enums have a |
I'm not against allowing empty enums. |
Would it be safe to include in the next minor release or even patch update? |
I think there are a number of issues to work out:
enumCases.last.pushAttachment(DesugarEnums.DefinesEnumLookupMethods, ()) |
There is also the decision of if we will synthesize sum mirrors with no cases: #11764, which I think was previously decided no because code in community build assumes there will be at least one case (I guess libraries could release minor update to support zero-cases) This can still be orthogonal to if enum will compile with zero cases |
Uh oh!
There was an error while loading. Please reload this page.
In IntelliJ Scala Plugin there is an action which creates a new Class/Object/File/Enum:

When you create class/object/file it creates a tiny template which is compilable.

However in Scala 3 enum can't have zero cases.
So the template for Scala 3 enum produces code with error "Enumerations must contain at least one case"
It's not an issue with Java enum because Java supports enum with zero items.
I wonder is there a reason to make it an error?
I could write a
sealed class MyEnum
without any inheritors and the code would perfectly compile.Maybe it makes sense to remove the error?
Or at least make it a warning?
(also see SCL-20747)
The text was updated successfully, but these errors were encountered: