-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Empty enum bodies are accepted #5015
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
This is a parser issue: enum Foo extends AnyRef -- [E040] Syntax Error: tests/allan/Test.scala:99:23 ---------------------------
99 |enum Foo extends AnyRef
| ^
| '{' expected, but eof found |
Shouldn't we require enum to be non empty anyway? |
Oh right, that's actually required by the grammar (so this is a parser issue):
We should additionally require at least one EnumCase (in either Parser or Desugar), lest people write enum Root {
case class Foo()
} Defining case classes inside enums is legal but is most likely a typo. It seems hard to forbid (for consistency reasons) since enums can have arbitrary members, tho maybe we should anyway — this looks very much likely a future wart. |
Fix #5015: disallow empty enum definition
Uh oh!
There was an error while loading. Please reload this page.
After
enum A extends AnyRef
the REPL thinks the line is not over and requires braces. The REPL should instead do the same it does for classes:(noticed while testing #5008).
EDIT:
enum A extends AnyRef {}
is forbidden by the grammar, see below.The text was updated successfully, but these errors were encountered: