This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/master by this push:
     new fb8b711930 GROOVY-3908: groovyc should enforce correct usage of 
"continue"(add a test case)
fb8b711930 is described below

commit fb8b7119304752e0d931638daac793a4a81295df
Author: Daniel Sun <[email protected]>
AuthorDate: Sat Apr 12 12:53:05 2025 +0900

    GROOVY-3908: groovyc should enforce correct usage of "continue"(add a test 
case)
---
 .../groovy/parser/antlr4/SyntaxErrorTest.groovy     | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/src/test/org/apache/groovy/parser/antlr4/SyntaxErrorTest.groovy 
b/src/test/org/apache/groovy/parser/antlr4/SyntaxErrorTest.groovy
index 9d5b789773..748db1fd8c 100644
--- a/src/test/org/apache/groovy/parser/antlr4/SyntaxErrorTest.groovy
+++ b/src/test/org/apache/groovy/parser/antlr4/SyntaxErrorTest.groovy
@@ -395,6 +395,27 @@ final class SyntaxErrorTest {
             |'''.stripMargin()
     }
 
+    @Test // GROOVY-3908: groovyc should enforce correct usage of "continue"
+    void 'groovy core - Continue 1'() {
+        expectParseError '''\
+            |class UseContinueAsGoto {
+            |   static main(args) {
+            |     continue label1
+            |     return
+            |
+            |     label1:
+            |     println "Groovy supports goto!"
+            |   }
+            |}
+            |'''.stripMargin(), '''\
+            |continue statement is only allowed inside loops @ line 3, column 
6.
+            |        continue label1
+            |        ^
+            |
+            |1 error
+            |'''.stripMargin()
+    }
+
     @Test
     void 'groovy core - void'() {
         TestUtils.doRunAndShouldFail('fail/Void_01x.groovy')

Reply via email to