diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2013-02-10 15:40:01 +0100 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2013-03-29 19:22:02 +0100 |
commit | 530f4a544b95d77eff378d31122615eea195618a (patch) | |
tree | b3da412c8778983b1f2c1db40cebf4761aba02dd /test/files/neg/t7110.flags | |
parent | 1debc74374e9c3de52d1333b695db61e7a69a57b (diff) | |
download | scala-530f4a544b95d77eff378d31122615eea195618a.tar.gz scala-530f4a544b95d77eff378d31122615eea195618a.tar.bz2 scala-530f4a544b95d77eff378d31122615eea195618a.zip |
SI-7110 Warn about naked try without catch/finally
Before, this was allowed:
scala> try ( 1 / 0 )
java.lang.ArithmeticException: / by zero
But since the advent of util.Try, the subtle difference to the
following seems dangerous:
scala> import util.Try
import util.Try
scala> Try ( 1 / 0 )
res4: scala.util.Try[Int] = Failure(java.lang.ArithmeticException: / by zero)
Discussion: https://groups.google.com/d/topic/scala-language/fy2vXD_3fF8/discussion
There was some concern that this curtails a handy, temporary
way to remove the exception handlers from some code. But after
thinking about this, I contend that:
a) those people can easily stomach the warning temporarily
(modulo, of course, those with -Xfatal-warnings.)
b) putting this warning behind Xlint will disable it for those
who need it most: beginners.
I also chose not to refer to 'scala.util.Try' in the error message
as I think that has as much potential to confuse as it does to clarify.
Diffstat (limited to 'test/files/neg/t7110.flags')
-rw-r--r-- | test/files/neg/t7110.flags | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/test/files/neg/t7110.flags b/test/files/neg/t7110.flags new file mode 100644 index 0000000000..e8fb65d50c --- /dev/null +++ b/test/files/neg/t7110.flags @@ -0,0 +1 @@ +-Xfatal-warnings
\ No newline at end of file |