sealed trait OpError
sealed trait RequestErrorType
sealed trait ProcessingErrorType
final case class InvalidEndpoint(reason: String) extends RequestErrorType
final case class InvalidParameters(reason: String) extends RequestErrorType
final case class InvalidFormat(response: String) extends ProcessingErrorType
final case class EntityNotFound(id: Long) extends ProcessingErrorType
final case class RequestError(errorType: RequestErrorType) extends OpError
final case class ProcessingError(errorType: ProcessingErrorType) extends OpError
If I write a simple match across all patterns:
def printMatches(error: OpError): Unit = error match {
case RequestError(InvalidEndpoint(reason)) => //print something
case RequestError(InvalidParameters(reason)) => //print something
case ProcessingError(InvalidFormat(format)) => //print something
case ProcessingError(EntityNotFound(entityId)) => //print something
}
the compiler gives me a warning about missing match:
match may not be exhaustive.
It would fail on the following input: ProcessingError(_)
def printMatches(error: OpError): Unit = error match {
But ProcessingError takes in a ProcessingErrorType with only two extensions: InvalidFormat and EntityNotFound, both which are accounted for in the pattern match. Am I missing a match or could this be a compiler bug? I'm using Scala 2.11.7.
Note: I've already asked this question on SO without any resolution.
--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
-John
sealed trait InnerBlah final case class Blee(value: String) extends InnerBlah final case class Blue(value: String) extends InnerBlah
sealed trait Blah final case class OneBlah(value: InnerBlah) extends Blah
def printBlah(blah: Blah): Unit = blah match { case OneBlah(Blee(v)) => println(s"got a Blee($v)") case OneBlah(Blue(v)) => println(s"got a Blah($v)") }
--
You received this message because you are subscribed to a topic in the Google Groups "scala-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/scala-user/FGUwP38pQ3o/unsubscribe.
To unsubscribe from this group and all its topics, send an email to scala-user+...@googlegroups.com.
Same point for all the soundness bugs in the database
--
I don't think anyone is assuming malice. The disappointment is that is isn't receiving higher priority. Bugs in exhaustiveness checking mean that we can't rely on compilation to prove that our programs are correct - that's way more critical and important than a new backend, new optimiser, SAMs and all the other (good) stuff in 2.12.
I've made some progress in this area in https://github.com/scala/scala/pull/4919David: If you have any other exhaustivity/reachability related issues in JIRA that have I haven't mentioned in this pull request, please mention me on the ticket and I'll see if this patch fixes them too.