We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Another "unreachable code" issue; I've reproduced it in 2.10.1 and a 2.11 nightly build.
Welcome to Scala version 2.11.0-20130410-113912-f6323d866f (OpenJDK 64-Bit Server VM, Java 1.7.0_15). Type in expressions to have them evaluated. Type :help for more information. scala> val X = true X: Boolean = true scala> val O = false O: Boolean = false scala> def classify(neighbourhood: (Boolean, Boolean, Boolean)): String = { | neighbourhood match { | case (X, X, X) => "middle" | case (X, X, O) => "right" | case (O, X, X) => "left" | case _ => throw new IllegalArgumentException("Invalid") | } | } <console>:12: warning: unreachable code case (X, X, O) => "right" ^ classify: (neighbourhood: (Boolean, Boolean, Boolean))String scala> classify(true, true, false) res0: String = right scala> classify(false, true, true) res1: String = left
Welcome to Scala version 2.10.1 (OpenJDK 64-Bit Server VM, Java 1.7.0_15). Type in expressions to have them evaluated. Type :help for more information. scala> val X = true X: Boolean = true scala> val O = false O: Boolean = false scala> def classify(neighbourhood: (Boolean, Boolean, Boolean)): String = { | neighbourhood match { | case (X, X, X) => "middle" | case (X, X, O) => "right" | case (O, X, X) => "left" | case _ => throw new IllegalArgumentException("Invalid") | } | } <console>:12: warning: unreachable code case (X, X, O) => "right" ^ classify: (neighbourhood: (Boolean, Boolean, Boolean))String scala> classify(true, true, false) res0: String = right
The text was updated successfully, but these errors were encountered:
Imported From: https://issues.scala-lang.org/browse/SI-7369?orig=1 Reporter: Joaquin Caraballo (jcaraballo) Affected Versions: 2.10.1 See #6771
Sorry, something went wrong.
@retronym said: Cut down a little:
val X, Y = true (null: Tuple1[Boolean]) match { case Tuple1(X) => case Tuple1(Y) => // unreachable case _ => } val X, Y = "" (null: Tuple1[String]) match { case Tuple1(X) => case Tuple1(Y) => // no warning case _ => }
@retronym said: Also interesting for comparison:
sealed abstract class B; case object True extends B; case object False extends B; object Test2 { val X: B = True val Y: B = False (null: Tuple1[B]) match { case Tuple1(X) => case Tuple1(Y) => // no warning case _ => } }
reachable: -V1=null#1 /\ V2=Y#3 under prefix: V2=False.type#4 \/ V2=True.type#5 \/ V2=null#6 /\ -V2=Y#3 \/ -V2=X#2 \/ /\ -V2=Y#3 \/ -V2=null#6 \/ /\ -V2=False.type#4 \/ -V2=null#6 \/ /\ -V2=X#2 \/ -V2=null#6 \/ /\ -V2=True.type#5 \/ -V2=null#6 \/ /\ V1=null#1 \/ -V2=X#2 \/ via Map(V2=Y#3 -> true, V2=False.type#4 -> true, V2=X#2 -> false, V1=null#1 -> false, V2=null#6 -> false)
Compare with the unsatisfiable model for:
object Test { val X, Y = true (null: Tuple1[Boolean]) match { case Tuple1(X) => case Tuple1(Y) => // unreachable case _ => } }
unreachable: -V1=null#1 /\ V2=Y#3 under prefix: V2=true#4 \/ V2=false#5 /\ -V2=X#2 \/ -V2=false#5 /\ -V2=X#2 \/ -V2=Y#3 /\ -V2=X#2 \/ -V2=true#4 /\ -V2=false#5 \/ -V2=Y#3 /\ -V2=false#5 \/ -V2=true#4 /\ -V2=Y#3 \/ -V2=true#4 /\ V1=null#1 \/ -V2=X#2
@retronym said: scala/scala#2439
retronym
No branches or pull requests
Another "unreachable code" issue; I've reproduced it in 2.10.1 and a 2.11 nightly build.
The text was updated successfully, but these errors were encountered: