You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2022/07/02 03:47:26 UTC

[groovy] branch GROOVY-10659 updated (3146d0596d -> bfcbefd957)

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

sunlan pushed a change to branch GROOVY-10659
in repository https://gitbox.apache.org/repos/asf/groovy.git


 discard 3146d0596d GROOVY-10659: Parrot Parser: named arguments does not support all key expressions
     new bfcbefd957 GROOVY-10659: Parrot Parser: named arguments does not support all key expressions

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (3146d0596d)
            \
             N -- N -- N   refs/heads/GROOVY-10659 (bfcbefd957)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/antlr/GroovyParser.g4                       |  1 +
 src/test-resources/bugs/BUG-GROOVY-10659.groovy | 11 +++++++++++
 src/test/groovy/bugs/Groovy10659.groovy         | 19 +++++++++++++++----
 3 files changed, 27 insertions(+), 4 deletions(-)


[groovy] 01/01: GROOVY-10659: Parrot Parser: named arguments does not support all key expressions

Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit bfcbefd957426fc75db59e32cfa37cf89c313942
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sat Jul 2 11:26:19 2022 +0800

    GROOVY-10659: Parrot Parser: named arguments does not support all key expressions
---
 src/antlr/GroovyParser.g4                          |  2 +
 src/test-resources/bugs/BUG-GROOVY-10659.groovy    | 34 ++++++++++++
 src/test/groovy/bugs/Groovy10659.groovy            | 61 ++++++++++++++++++++++
 .../groovy/parser/antlr4/GroovyParserTest.groovy   |  4 ++
 4 files changed, 101 insertions(+)

diff --git a/src/antlr/GroovyParser.g4 b/src/antlr/GroovyParser.g4
index 9d26199ffe..bffe4aa6d3 100644
--- a/src/antlr/GroovyParser.g4
+++ b/src/antlr/GroovyParser.g4
@@ -1053,6 +1053,8 @@ options { baseContext = primary; }
     |   literal                                                                             #literalPrmrAlt
     |   gstring                                                                             #gstringPrmrAlt
     |   parExpression                                                                       #parenPrmrAlt
+    |   list                                                                                #listPrmrAlt
+    |   map                                                                                 #mapPrmrAlt
     ;
 
 namedArgPrimary
diff --git a/src/test-resources/bugs/BUG-GROOVY-10659.groovy b/src/test-resources/bugs/BUG-GROOVY-10659.groovy
new file mode 100644
index 0000000000..b4a89eeb18
--- /dev/null
+++ b/src/test-resources/bugs/BUG-GROOVY-10659.groovy
@@ -0,0 +1,34 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+fun (
+        x: 1,
+        [a: 1]: '2'
+)
+
+fun (
+        x: 1,
+        [1, 2]: '2'
+)
+
+fun (
+        x: 1,
+        [a: 1]: '2',
+        [1, 2]: '2'
+)
diff --git a/src/test/groovy/bugs/Groovy10659.groovy b/src/test/groovy/bugs/Groovy10659.groovy
new file mode 100644
index 0000000000..e3f3c3178c
--- /dev/null
+++ b/src/test/groovy/bugs/Groovy10659.groovy
@@ -0,0 +1,61 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package bugs
+
+import groovy.transform.CompileStatic
+import org.junit.Test
+
+import static groovy.test.GroovyAssert.assertScript
+
+@CompileStatic
+class Groovy10659 {
+    @Test
+    void test() {
+        assertScript '''
+            def fun = { arg ->
+                return arg
+            }
+            
+            def r = fun (
+                x: 1,
+                [a: 1]: '2'
+            )
+            assert '[x:1, [a:1]:2]' == r.toString()
+            
+            r = fun ([
+                x: 1,
+                [a: 1]: '2'
+            ]) 
+            assert '[x:1, [a:1]:2]' == r.toString()
+            
+            r = fun (
+                x: 1,
+                [1, 2]: '2'
+            )
+            assert '[x:1, [1, 2]:2]' == r.toString()
+            
+            r = fun (
+                x: 1,
+                [a: 1]: '2',
+                [1, 2]: '2'
+            )
+            assert '[x:1, [a:1]:2, [1, 2]:2]' == r.toString()
+        '''
+    }
+}
diff --git a/src/test/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy b/src/test/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy
index 0919c4fbcc..9099bac62f 100644
--- a/src/test/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy
+++ b/src/test/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy
@@ -529,4 +529,8 @@ final class GroovyParserTest extends GroovyTestCase {
     void "test groovy core - GROOVY-10406"() {
         doTest('bugs/BUG-GROOVY-10406.groovy');
     }
+
+    void "test groovy core - GROOVY-10659"() {
+        doTest('bugs/BUG-GROOVY-10659.groovy');
+    }
 }