diff options
author | Lukas Rytz <lukas.rytz@gmail.com> | 2016-11-09 14:10:59 +0100 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@gmail.com> | 2016-11-09 14:42:01 +0100 |
commit | c1e9b0a951ee5298244c6456af3641ee966e101b (patch) | |
tree | f090170211e20b101d7477e9b269a7c0d10d945a /versions.properties | |
parent | f297ca8d1f06086316ff3746250092e36ef9f74e (diff) | |
download | scala-c1e9b0a951ee5298244c6456af3641ee966e101b.tar.gz scala-c1e9b0a951ee5298244c6456af3641ee966e101b.tar.bz2 scala-c1e9b0a951ee5298244c6456af3641ee966e101b.zip |
Fix returns from within finalizers
When a return in a finalizer was reached through a return within the try
block, the backend ignored the return in the finalizer:
try {
try { return 1 }
finally { return 2 }
} finally { println() }
This expression should evaluate to 2 (it does in 2.11.8), but in 2.12.0
it the result is 1.
The Scala spec is currently incomplete, it does not say that a finalizer
should be exectuted if a return occurs within a try block, and it does
not specify what happens if also the finally block has a return.
So we follow the Java spec, which basically says: if the finally blocks
completes abruptly for reason S, then the entire try statement completes
abruptly with reason S. An abrupt termination of the try block for a
different reason R is discarded.
Abrupt completion is basically returning or throwing.
Diffstat (limited to 'versions.properties')
0 files changed, 0 insertions, 0 deletions