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

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


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

commit be69403dd5c74430fba18da782de2701c6477fa0
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)
    
    (cherry picked from commit fb8b7119304752e0d931638daac793a4a81295df)
---
 .../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 68a7f5497d..33d62043ed 100644
--- a/src/test/org/apache/groovy/parser/antlr4/SyntaxErrorTest.groovy
+++ b/src/test/org/apache/groovy/parser/antlr4/SyntaxErrorTest.groovy
@@ -377,6 +377,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 'test groovy core - void'() {
         TestUtils.doRunAndShouldFail('fail/Void_01x.groovy')

Reply via email to