Skip to content
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

Pattern matcher exhaustivity regression in 2.10.4-RC3, fixed in 2.11 #8412

Closed
scabug opened this issue Mar 14, 2014 · 3 comments
Closed

Pattern matcher exhaustivity regression in 2.10.4-RC3, fixed in 2.11 #8412

scabug opened this issue Mar 14, 2014 · 3 comments
Assignees
Labels
Milestone

Comments

@scabug
Copy link

scabug commented Mar 14, 2014

I did my best to find the corresponding issue, but I couldn't pinpoint it. Here's what happens:

$ cat Test.scala 
package test

sealed trait Tree
case class Let(sth: List[Any]) extends Tree
case class Lit(sth: Any) extends Tree

object Test {
  def wroong(tree: Tree) =
    tree match {
      case Let(_ :: rest) =>
        ???
      case Let(Nil) =>
        ???
      // no warning for missing Lit(_) in 2.10
    }
}

$ scalac210 -version
Scala compiler version 2.10.4-20140209-180020-b66a39653b -- Copyright 2002-2013, LAMP/EPFL

$ scalac210 Test.scala 

$ scalac210 -Xoldpatmat Test.scala #using the old pattern matcher
Test.scala:10: warning: match is not exhaustive!
missing combination            Lit

    tree match {
    ^
one warning found

$ scalac211 -version
Scala compiler version 2.11.0-20140227-142303-fabc9f1424 -- Copyright 2002-2013, LAMP/EPFL

$ scalac211 Test.scala 
Test.scala:10: warning: match may not be exhaustive.
It would fail on the following input: Lit(_)
    tree match {
    ^
one warning found

Yet, when I join the two cases, the warning appears:

$ cat Test2.scala 
package test

sealed trait Tree
case class Let(sth: List[Any]) extends Tree
case class Lit(sth: Any) extends Tree

object Test {

  def ookay(tree: Tree) =
    tree match {
      case Let(_) =>
        ???
      // missing Lit(_) warning in both 2.10 and 2.11
    }
}

$ scalac Test2.scala 
Test2.scala:10: warning: match may not be exhaustive.
It would fail on the following input: Lit(_)
    tree match {
    ^
one warning found
@scabug
Copy link
Author

scabug commented Mar 14, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8412?orig=1
Reporter: @VladUreche
Affected Versions: 2.10.4-RC3

@scabug
Copy link
Author

scabug commented Mar 18, 2014

@gkossakowski said:
Thanks for the report!

Just to clarify, it regressed in Scala 2.10.0 and the regression is still presented in 2.10.4-RC3. The issue is fixed in Scala 2.11.0-RC1 so I'm closing it.

@scabug scabug closed this as completed Mar 18, 2014
@scabug
Copy link
Author

scabug commented Mar 18, 2014

@VladUreche said:
Thanks Greg!

@scabug scabug added the patmat label Apr 7, 2017
@scabug scabug added this to the 2.11.0-RC1 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants