From cb91343d2b02b038f6c297ba79a052e0758caae8 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Tue, 28 Sep 2010 15:43:32 +0000 Subject: Fix and test case for #3855. situations where a mutable var will later be lifted. As a point of interest, this bug reveals itself fairly clearly if you use a build since r23112 and run the checker thusly: scalac -d /tmp -Ycheck-debug -Ycheck:icode -Xprint:icode test/files/run/bug3855.scala It dies with the following explanation: Output changed for Block 3 [S: 2] [P: 1, 4] Exception in thread "main" scala.tools.nsc.backend.icode.CheckerException: Incompatible stacks: TypeStack() and TypeStack(2 elems) { REFERENCE(class IntRef) REFERENCE(class IntRef) } in Test.main at entry to block: 2 And indeed that was the source of the reported verifyerror. Review by i. dragos. --- test/files/run/bug3855.scala | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 test/files/run/bug3855.scala (limited to 'test') diff --git a/test/files/run/bug3855.scala b/test/files/run/bug3855.scala new file mode 100644 index 0000000000..32dfb1e23d --- /dev/null +++ b/test/files/run/bug3855.scala @@ -0,0 +1,18 @@ +object Test { + def byval[A](a: => A) = a + def closure[A](f: () => A) = f() + + def f1(s: String) = { + var n = try { s.toInt } catch { case _ => 1 } + byval(n) + } + def f2(s: String) = { + var n = try { s.toInt } catch { case _ => 1 } + closure(() => n) + } + + def main(args: Array[String]) = { + val sum = f1("12") + f2("the witch is dead") + assert(sum == 13) + } +} -- cgit v1.2.3