diff options
author | Paul Phillips <paulp@improving.org> | 2010-09-28 15:43:32 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-09-28 15:43:32 +0000 |
commit | cb91343d2b02b038f6c297ba79a052e0758caae8 (patch) | |
tree | 3165095121f5b2e02ad134bbac42dc2f2f276572 /test | |
parent | c18c3e108131bbfd6d2c4bbc3395c3a7f76a581b (diff) | |
download | scala-cb91343d2b02b038f6c297ba79a052e0758caae8.tar.gz scala-cb91343d2b02b038f6c297ba79a052e0758caae8.tar.bz2 scala-cb91343d2b02b038f6c297ba79a052e0758caae8.zip |
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.
Diffstat (limited to 'test')
-rw-r--r-- | test/files/run/bug3855.scala | 18 |
1 files changed, 18 insertions, 0 deletions
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) + } +} |