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 check incomplete and non-determistic #8430

Closed
scabug opened this issue Mar 19, 2014 · 7 comments
Closed

Pattern matcher exhaustivity check incomplete and non-determistic #8430

scabug opened this issue Mar 19, 2014 · 7 comments
Assignees
Labels
Milestone

Comments

@scabug
Copy link

scabug commented Mar 19, 2014

$ cat Test.scala
package test

sealed trait CL3Literal
case object IntLit extends CL3Literal
case object CharLit extends CL3Literal
case object BooleanLit extends CL3Literal
case object UnitLit extends CL3Literal


sealed trait Tree
case class LetL(value: CL3Literal) extends Tree
case object LetP extends Tree
case object LetC extends Tree
case object LetF extends Tree

object Test {
  def transform(tree: Tree) : Any = tree match {
    case LetL(CharLit) =>
      ???
  }
}
$ scalac Test.scala
Test.scala:17: warning: match may not be exhaustive.
It would fail on the following inputs: ??, LetC, LetF, LetL(IntLit), LetP
  def transform(tree: Tree) : Any = tree match {
                                    ^
one warning found
$ scalac Test.scala
Test.scala:17: warning: match may not be exhaustive.
It would fail on the following inputs: ??, LetC, LetF, LetL(BooleanLit), LetL(IntLit), LetP
  def transform(tree: Tree) : Any = tree match {
                                    ^
one warning found

Running "scalac Test.scala" will output randomly one of the two warning messages above. One of them is more complete than the other, but is still missing the LetL(UnitLit) case.

@scabug
Copy link
Author

scabug commented Mar 19, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8430?orig=1
Reporter: Guillaume Martres (Smarter)
Affected Versions: 2.11.0-RC1

@scabug
Copy link
Author

scabug commented Mar 19, 2014

@VladUreche said:
Thanks a lot for the report Guillaume, it's very good that you isolated the problem!
Adriaan, I marked it as critical since it's non-deterministic, but feel free to bump it back to major.

@scabug
Copy link
Author

scabug commented Mar 19, 2014

@VladUreche said:
This bug also affects RC3:

> clean
[success] Total time: 0 s, completed Mar 20, 2014 12:25:59 AM
> compile
[info] Updating {file:/mnt/data-local/Work/Workspace/dev/test/}default-827862...
[info] Resolving org.scala-lang#scala-library;2.11.0-RC3 ...
[info] Done updating.
[info] Compiling 1 Scala source to /mnt/data-local/Work/Workspace/dev/test/target/scala-2.11.0-RC3/classes...
[warn] /mnt/data-local/Work/Workspace/dev/test/src/main/scala/test.scala:17: match may not be exhaustive.
[warn] It would fail on the following inputs: ??, LetC, LetF, LetL(BooleanLit), LetL(IntLit), LetP
[warn]   def transform(tree: Tree) : Any = tree match {
[warn]                                     ^
[warn] one warning found
[success] Total time: 2 s, completed Mar 20, 2014 12:26:01 AM
> clean  
[success] Total time: 0 s, completed Mar 20, 2014 12:26:04 AM
> compile
[info] Updating {file:/mnt/data-local/Work/Workspace/dev/test/}default-827862...
[info] Resolving org.scala-lang#scala-library;2.11.0-RC3 ...
[info] Done updating.
[info] Compiling 1 Scala source to /mnt/data-local/Work/Workspace/dev/test/target/scala-2.11.0-RC3/classes...
[warn] /mnt/data-local/Work/Workspace/dev/test/src/main/scala/test.scala:17: match may not be exhaustive.
[warn] It would fail on the following inputs: ??, LetC, LetF, LetL(IntLit), LetP
[warn]   def transform(tree: Tree) : Any = tree match {
[warn]                                     ^
[warn] one warning found
[success] Total time: 1 s, completed Mar 20, 2014 12:26:06 AM

@scabug
Copy link
Author

scabug commented Mar 19, 2014

@adriaanm said:
Thanks! This is not a blocker bug, though. We'll fix it in 2.11.1.

@scabug
Copy link
Author

scabug commented Mar 21, 2014

@retronym said:
Here's a bashy way to test this:

% (f=test/files/neg/t8430.scala; (for i in {1..20}; do echo $f; done; printf "\n") | qbin/scalac -Xresident) 2>&1 | grep "fail" | sort | uniq | wc -l
       2

@scabug
Copy link
Author

scabug commented Mar 21, 2014

@scabug scabug closed this as completed Apr 21, 2014
@scabug
Copy link
Author

scabug commented Apr 21, 2014

@retronym said:
From the fix comment:

The counter-examples are still a bit off; I'm going to merge
that aspect of this ticket with SI-7746, in which we've
pinpointed the culpable part of the implementation, but haven't
had success in fixing the bug.

@scabug scabug added this to the 2.11.1 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