diff options
author | Martin Odersky <odersky@gmail.com> | 2015-08-14 18:57:34 -0700 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2015-08-15 13:55:31 -0700 |
commit | edaa193aac1d7880a81cd6a836fe3d7c3d652d45 (patch) | |
tree | 562dd22cbddd781f148a97d74a967fe640b6666e /tests/run | |
parent | b30843c59757ccaaf00c6733bf81f15eb911e6c2 (diff) | |
download | dotty-edaa193aac1d7880a81cd6a836fe3d7c3d652d45.tar.gz dotty-edaa193aac1d7880a81cd6a836fe3d7c3d652d45.tar.bz2 dotty-edaa193aac1d7880a81cd6a836fe3d7c3d652d45.zip |
Fix CaputuredVars/LiftTry interaction.
CapturedVars introduced an assignment that could cause a try to be
executed with a non-empty stack, even after LiftTry had already run.
We now avoid this by introducing a temporary variable.
Diffstat (limited to 'tests/run')
-rw-r--r-- | tests/run/liftedTry.scala | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/tests/run/liftedTry.scala b/tests/run/liftedTry.scala index 2e4c25c2b..0d956fc1f 100644 --- a/tests/run/liftedTry.scala +++ b/tests/run/liftedTry.scala @@ -12,10 +12,20 @@ object Test { foo(try 3 catch handle) - def main(args: Array[String]) = { + def main(args: Array[String]): Unit = { assert(x == 1) assert(foo(2) == 2) assert(foo(try raise(3) catch handle) == 3) + Tr.foo } } + +object Tr { + def fun(a: Int => Unit) = a(2) + def foo: Int = { + var s = 1 + s = try {fun(s = _); 3} catch{ case ex: Throwable => s = 4; 5 } + s + } +} |