[
https://issues.apache.org/jira/browse/JEXL-271?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Henri Biestro resolved JEXL-271.
--------------------------------
Resolution: Fixed
Fix Version/s: 3.2
- simplified curry(...) after being reminded it was a form of closure (thanks
Dmitri)
commit 2fdb4278d755b85c9c1d9f767a92bde1b9d098cb
src/main/java/org/apache/commons/jexl3/internal/Closure.java
src/main/java/org/apache/commons/jexl3/internal/Interpreter.java
src/main/java/org/apache/commons/jexl3/internal/Script.java
src/test/java/org/apache/commons/jexl3/Issues200Test.java
> Hoisted variable is lost when currying lambda
> ---------------------------------------------
>
> Key: JEXL-271
> URL: https://issues.apache.org/jira/browse/JEXL-271
> Project: Commons JEXL
> Issue Type: Bug
> Affects Versions: 3.1
> Reporter: Dmitri Blinov
> Assignee: Henri Biestro
> Priority: Major
> Fix For: 3.2
>
>
> I have noticed that when I curry the lambda that contains hoisted variable,
> then binding to that variable is lost when I call curried lambda. The
> following test case illustrates the problem
> {code}
> @Test
> public void testCurry4() throws Exception {
> JexlEngine jexl = new JexlBuilder().strict(false).create();
> JexlScript base = jexl.createScript("var base = 2; var sum = (x, y,
> z)->{ base + x + y + z }; var y = sum.curry(1); y(2,3)");
> Object result = base.execute(null);
> Assert.assertEquals(8, result);
> }
> {code}
> To put it another way, the following script returns {{2}} when it should
> return {{0}};
> {code}var base = 2; var sum = (x, y, z)->{ base + x + y + z }; var y =
> sum.curry(1); sum(1, 2, 3) - y(2,3){code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)