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
Using Enumeration values to match will compile even when match is not exhaustive #4333
Comments
Imported From: https://issues.scala-lang.org/browse/SI-4333?orig=1 |
@retronym said: That doesn't apply for |
@oxbowlakes said: a) it breaks the principle of least surprise |
@retronym said: Perhaps this could provided by an IDE inspection. But I doubt you'll convince anyone that it could or should go in the pattern matcher, circa 2011. |
@acruise said: CODE SKETCH, DO NOT COMPILE case class sealed(value: Seq[_ <: Enumeration#Value] extends Annotation
object Foo extends Enumeration {
@sealed(List(Foo1,Foo2)) // Probably doable, but smelly repetition
@sealed(values) // Too bad values is a def, not a stable identifier
case class FooValue(i: Int, s: String, d: Double) extends Value(i, s)
type Foo = FooValue
val Foo1 = Foo(1,"One",1.0)
val Foo2 = Foo(2,"Two",2.0)
} |
@acruise said:
I guess that should be Seq[Any] or Seq[_] to avoid special-casing enumerations in the compiler. :) |
@retronym said: You can pass type parameters though. |
I think this following snippet should not compile (because the match does not contain an exhaustive set of cases):
It compiles and produces a MatchError at runtime:
Using scala 2.8.1.
The text was updated successfully, but these errors were encountered: