diff options
author | Felix Mulder <felix.mulder@gmail.com> | 2016-09-14 11:11:24 +0200 |
---|---|---|
committer | Felix Mulder <felix.mulder@gmail.com> | 2016-09-15 16:13:34 +0200 |
commit | a73fd7790c7ef788d8718b09b93e8ba494b31778 (patch) | |
tree | 043a5ccee5d5c2891b5ad6ea707fbb9729ad2960 /src/dotty/tools/dotc/parsing | |
parent | 70a8426912f6f256536470a046cdf86827ab2c93 (diff) | |
download | dotty-a73fd7790c7ef788d8718b09b93e8ba494b31778.tar.gz dotty-a73fd7790c7ef788d8718b09b93e8ba494b31778.tar.bz2 dotty-a73fd7790c7ef788d8718b09b93e8ba494b31778.zip |
Allow try expression without catch or finally, issue warning
Diffstat (limited to 'src/dotty/tools/dotc/parsing')
-rw-r--r-- | src/dotty/tools/dotc/parsing/Parsers.scala | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/parsing/Parsers.scala b/src/dotty/tools/dotc/parsing/Parsers.scala index 378aa6ed7..4bc706436 100644 --- a/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/src/dotty/tools/dotc/parsing/Parsers.scala @@ -1010,8 +1010,13 @@ object Parsers { expr() } else EmptyTree val finalizer = - if (handler.isEmpty || in.token == FINALLY) { accept(FINALLY); expr() } - else EmptyTree + if (in.token == FINALLY) { accept(FINALLY); expr() } + else { + if (handler.isEmpty) + warning("A try without `catch` or `finally` is equivalent to putting its body in a block; no exceptions are handled.") + + EmptyTree + } ParsedTry(body, handler, finalizer) } case THROW => |