code |
object TestVerifier
{
// Both f and g cause the problem, h doesn't.
// They don't need to be called, just class loaded.
// Fwiw, the loop after the inner match is required - removing it makes the problem vanish.
def f() =
{
val x : Option[Int] = Some(0)
x match
{
case None =>
case Some(_) =>
var y = List(1)
y.length match
{
case 0 => 0
case 1 =>
case _ => 1
}
for(val z <- y)
{
}
}
}
def g() =
{
val x : Option[Int] = Some(0)
x match
{
case None =>
case Some(_) =>
var y = List(1)
y.length match
{
case 0 => 0
case 1 => ()
case _ => 1
}
for(val z <- y)
{
}
}
}
def h() =
{
def p() =
{
var y = List(1)
y.length match
{
case 0 => 0
case 1 =>
case _ => 1
}
for(val z <- y)
{
}
}
val x : Option[Int] = Some(0)
x match
{
case None =>
case Some(_) =>
p
}
}
def main(args: Array[String]): Unit =
{
}
}
/*
$ scalac TestVerifier.scala && scala TestVerifier
java.lang.VerifyError: (class: TestVerifier$, method: f signature: ()V) Inconsistent stack height 1 != 0
at TestVerifier.main(TestVerifier.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at scala.tools.nsc.ObjectRunner$.run(ObjectRunner.scala:73)
at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:133)
at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)
*/
|