2013/7/17 Mark Thomas wrote:
>
> On 17/07/2013 12:43, Mark Thomas wrote:
> > Violeta Georgieva <miles...@gmail.com> wrote:
> >
> >> Having the example from the test:
> >> (x->y->x-y)(2)(1)
> >>
> >> We may transform it like this:
> >> (()->y->2-y)()(1)
> >>
> >> So instead of returning right way when formalParameters.isEmpty()
> >>
> >> Shouldn't we have something like the one below in order to continue
> >> evaluation of the nested expression:
> >>
> >>
> >>
> >> --- org/apache/el/parser/AstLambdaExpression.java (revision 1504024)
> >> +++ org/apache/el/parser/AstLambdaExpression.java (working copy)
> >> @@ -54,9 +54,12 @@
> >>      LambdaExpression le = new LambdaExpression(formalParameters, ve);
> >>         le.setELContext(ctx);
> >>
> >> +        Object result = le;
> >> +        int i = 2;
> >>         if (formalParameters.isEmpty()) {
> >>             // No formal parameters - invoke the expression
> >> -            return le.invoke(ctx, (Object[]) null);
> >> +            result = ((LambdaExpression) result).invoke(ctx,
> >> (Object[])
> >> null);
> >> +            i++;
> >>         }
> >>
> >>       // If there are method parameters, need to invoke the expression
> >> with
> >> @@ -64,8 +67,6 @@
> >>         // should be that many nested expressions.
> >>      // If there are more nested expressions that parameters this will
> >> return
> >>         // a LambdaExpression
> >> -        Object result = le;
> >> -        int i = 2;
> >>         while (result instanceof LambdaExpression && i <
> >> jjtGetNumChildren()) {
> >>             result = ((LambdaExpression) result).invoke(
> >>                     ((AstMethodParameters)
> >> children[i]).getParameters(ctx));
> >
> > I agree the current solution isn't right but I have some local test
cases that I'm fairly sure will still fail with the above patch. I'm
working on a fix and should have something to commit soon.
>
> Fix applied. What do you think?


Why it is expected that (()->y->()->x->x-y)()(1)()(2) should throw
ELException? (TestAstLambdaExpression.testNested04())
Isn't it a correct one?

Reply via email to