You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by he...@apache.org on 2020/01/20 16:14:00 UTC
[commons-jexl] branch master updated: JEXL-307: fixing regression,
parameter declaration under lexical feature Task #JEXL-307 -
Variable redeclaration option
This is an automated email from the ASF dual-hosted git repository.
henrib pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-jexl.git
The following commit(s) were added to refs/heads/master by this push:
new f094271 JEXL-307: fixing regression, parameter declaration under lexical feature Task #JEXL-307 - Variable redeclaration option
f094271 is described below
commit f0942719bf96487596fa71f0b7fdcc1d004c34e0
Author: henrib <he...@apache.org>
AuthorDate: Mon Jan 20 17:12:31 2020 +0100
JEXL-307: fixing regression, parameter declaration under lexical feature
Task #JEXL-307 - Variable redeclaration option
---
.../java/org/apache/commons/jexl3/parser/JexlParser.java | 2 +-
src/test/java/org/apache/commons/jexl3/LexicalTest.java | 12 +++++++++++-
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/src/main/java/org/apache/commons/jexl3/parser/JexlParser.java b/src/main/java/org/apache/commons/jexl3/parser/JexlParser.java
index 8a5d51b..75de958 100644
--- a/src/main/java/org/apache/commons/jexl3/parser/JexlParser.java
+++ b/src/main/java/org/apache/commons/jexl3/parser/JexlParser.java
@@ -390,7 +390,7 @@ public abstract class JexlParser extends StringParser {
int symbol = frame.declareParameter(identifier);
// not sure how declaring a parameter could fail...
// lexical feature error
- if (!declareSymbol(symbol) && getFeatures().isLexical()) {
+ if (!block.declareSymbol(symbol) && getFeatures().isLexical()) {
JexlInfo xinfo = info.at(token.beginLine, token.beginColumn);
throw new JexlException(xinfo, identifier + ": variable is already declared", null);
}
diff --git a/src/test/java/org/apache/commons/jexl3/LexicalTest.java b/src/test/java/org/apache/commons/jexl3/LexicalTest.java
index 699f70a..2d7b820 100644
--- a/src/test/java/org/apache/commons/jexl3/LexicalTest.java
+++ b/src/test/java/org/apache/commons/jexl3/LexicalTest.java
@@ -728,5 +728,15 @@ public class LexicalTest {
Object result = script.execute(jc);
Assert.assertEquals(result, 42);
}
-
+
+ @Test
+ public void testNamed() throws Exception {
+ JexlFeatures f = new JexlFeatures();
+ f.lexical(true);
+ JexlEngine jexl = new JexlBuilder().strict(true).features(f).create();
+ JexlScript script = jexl.createScript("var i = (x, y, z)->{return x + y + z}; i(22,18,2)");
+ JexlContext jc = new MapContext();
+ Object result = script.execute(null);
+ Assert.assertEquals(result, 42);
+ }
}