groovy git commit: Tweak how grammar detects non try-with-resource case with no catch/finally

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

groovy git commit: Tweak how grammar detects non try-with-resource case with no catch/finally

paulk
Repository: groovy
Updated Branches:
  refs/heads/master e0b787dcf -> da240387d


Tweak how grammar detects non try-with-resource case with no catch/finally


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/da240387
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/da240387
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/da240387

Branch: refs/heads/master
Commit: da240387d469395de955bcd18d3d667d04875113
Parents: e0b787d
Author: paulk <[hidden email]>
Authored: Mon Sep 11 23:42:02 2017 +1000
Committer: paulk <[hidden email]>
Committed: Mon Sep 11 23:50:02 2017 +1000

----------------------------------------------------------------------
 src/main/antlr/GroovyParser.g4 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/da240387/src/main/antlr/GroovyParser.g4
----------------------------------------------------------------------
diff --git a/src/main/antlr/GroovyParser.g4 b/src/main/antlr/GroovyParser.g4
index d72b907..49877d7 100644
--- a/src/main/antlr/GroovyParser.g4
+++ b/src/main/antlr/GroovyParser.g4
@@ -663,8 +663,8 @@ locals[boolean resourcesExists = false]
         |
             nls finallyBlock
         |
-            // try-with-resources can have no catche and finally clauses
-            { $resourcesExists }?<fail={"catch or finally clauses are required for try-catch statement"}>
+            // catch and finally clauses required unless it's a try-with-resources block
+            { require($resourcesExists, "either a catch or finally clause or both is required for a try-catch-finally statement", -5); }
         )
     ;