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 2017/09/08 16:43:18 UTC
groovy git commit: GROOVY-8311: [Parrot]Failed to check duplicated
parameters properly
Repository: groovy
Updated Branches:
refs/heads/master 881219cc6 -> 0e0e650c2
GROOVY-8311: [Parrot]Failed to check duplicated parameters properly
Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/0e0e650c
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/0e0e650c
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/0e0e650c
Branch: refs/heads/master
Commit: 0e0e650c27637f00c6e926342a745a0d8be4303a
Parents: 881219c
Author: sunlan <su...@apache.org>
Authored: Sat Sep 9 00:43:05 2017 +0800
Committer: sunlan <su...@apache.org>
Committed: Sat Sep 9 00:43:05 2017 +0800
----------------------------------------------------------------------
.../apache/groovy/parser/antlr4/AstBuilder.java | 9 +++++++-
.../parser/antlr4/GroovyParserTest.groovy | 2 ++
.../test/resources/bugs/BUG-GROOVY-8311.groovy | 23 ++++++++++++++++++++
3 files changed, 33 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/groovy/blob/0e0e650c/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
index 7b63bee..ff7b5e9 100644
--- a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
+++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
@@ -2290,9 +2290,16 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object> implements Groov
return;
}
+ if (isInsideParentheses(keyExpression)) {
+ return;
+ }
+
String parameterName = keyExpression.getText();
- boolean isDuplicatedNamedParameter = mapEntryExpressionList.stream().anyMatch(m -> m.getKeyExpression().getText().equals(parameterName));
+ boolean isDuplicatedNamedParameter =
+ mapEntryExpressionList.stream()
+ .anyMatch(m -> m.getKeyExpression().getText().equals(parameterName));
+
if (!isDuplicatedNamedParameter) {
return;
}
http://git-wip-us.apache.org/repos/asf/groovy/blob/0e0e650c/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy b/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy
index 3410dd7..1241112 100644
--- a/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy
+++ b/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy
@@ -376,5 +376,7 @@ class GroovyParserTest extends GroovyTestCase {
doRunAndTest('bugs/GROOVY-3898.groovy');
doRunAndTest('bugs/GROOVY-8228.groovy');
+
+ doRunAndTest('bugs/BUG-GROOVY-8311.groovy');
}
}
http://git-wip-us.apache.org/repos/asf/groovy/blob/0e0e650c/subprojects/parser-antlr4/src/test/resources/bugs/BUG-GROOVY-8311.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/bugs/BUG-GROOVY-8311.groovy b/subprojects/parser-antlr4/src/test/resources/bugs/BUG-GROOVY-8311.groovy
new file mode 100644
index 0000000..dafa651
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/bugs/BUG-GROOVY-8311.groovy
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+def greet(args) {
+ [args.name, args.age]
+}
+def name = 'age'
+assert greet(name: 'Doe', (name): 8) == ['Doe', 8]