Aladdin - Scala Bugtracking
[#1235] project: compiler priority: low category: bug
submitter assigned to status date submitted
Nikolay Iulian fixed 2007-07-20 14:19:34.0
subject [contrib #710] verify error with match match loop
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)
*/


what happened
java.lang.VerifyError at runtime
what expected successful execution
[back to overview]
Changes of this bug report
Nikolay  edited on  2007-07-20 14:20:33.0
Iulian  edited on  2007-07-20 14:41:04.0