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

Spurious unreachable code warning in pattern matching #9369

Closed
scabug opened this issue Jun 30, 2015 · 8 comments
Closed

Spurious unreachable code warning in pattern matching #9369

scabug opened this issue Jun 30, 2015 · 8 comments
Assignees
Labels
Milestone

Comments

@scabug
Copy link

scabug commented Jun 30, 2015

This is a regression from 2.11.6:

trait Tree
sealed abstract class Prop
trait Simple extends Prop
case class Atom(tree: Tree) extends Prop with Simple
case class Not(prop: Prop) extends Prop with Simple

object Test {
  def main(args: Array[String]): Unit = {
    def simplify(prop: Prop): Prop = prop match {
      case Not(Atom(tree)) => ???
      case Not(Not(prop)) => ???
      case _ => ???
    }
  }
}
14:20 ~/Projects/2117/sandbox (HEAD)$ s
Test.scala:11: warning: unreachable code
      case Not(Not(prop)) => ???
                             ^
one warning found
@scabug
Copy link
Author

scabug commented Jun 30, 2015

Imported From: https://issues.scala-lang.org/browse/SI-9369?orig=1
Reporter: @xeno-by
Affected Versions: 2.11.7

@scabug
Copy link
Author

scabug commented Jun 30, 2015

@SethTisue said:
scala/scala#4379 and scala/scala#4431 seem like the obvious places to look

@scabug
Copy link
Author

scabug commented Jun 30, 2015

@retronym said:
Indeed:

% RUNNER=scalac scala-bisector v2.11.6 v2.11.7 sandbox/test.scala -Xfatal-warnings
...
8623c2be74f8de0c400dcc04eb6f83168c6272c0 is the first bad commit
bisect run success

scala/scala@8623c2b
scala/scala#4431

@scabug
Copy link
Author

scabug commented Jun 30, 2015

@retronym said:
/cc @gbasler

@scabug
Copy link
Author

scabug commented Jun 30, 2015

Tony Sloane (asloane) said:
We've seen a couple of these too. FWIW, the warning goes away if you seal the Simple trait.

@scabug
Copy link
Author

scabug commented Jul 12, 2015

@gbasler said:
I've checked this with the debugger: the reason for that behavior is the it thinks that the trait is mutually exclusive with the Not / And... I haven't found the time to investigate this further, hopefully in a weeks time...

@scabug
Copy link
Author

scabug commented Jul 13, 2015

@adriaanm said:
Thanks, Gerard!

@scabug
Copy link
Author

scabug commented Sep 14, 2015

@gbasler said:
scala/scala#4740

@scabug scabug closed this as completed Sep 14, 2015
@scabug scabug added the patmat label Apr 7, 2017
@scabug scabug added this to the 2.11.8 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