E145: Enumerations Should Not Be Empty
This error occurs when an enum is defined without any cases.
In Scala 3, enums must contain at least one case. An empty enum has no values and cannot be meaningfully used. If you need an empty sealed hierarchy, consider using a sealed trait instead.
Example
enum Empty {}
Error
-- [E145] Syntax Error: example.scala:1:5 --------------------------------------
1 |enum Empty {}
| ^^^^^
| Enumerations must contain at least one case
|-----------------------------------------------------------------------------
| Explanation (enabled by `-explain`)
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| Enumeration Empty must contain at least one case
| Example Usage:
| enum Empty {
| case Option1, Option2
| }
-----------------------------------------------------------------------------
Solution
// Add at least one case to the enum
enum Status {
case Active, Inactive
}
// Or use a sealed trait if no cases are needed yet
sealed trait Empty
In this article