TrigerSoft/jaque

Incorrect parameter reference in MemberExpression

Closed this issue · 4 comments

I've added an example for my problem below.
I am working on support for Java functions inside lambdas. But when traversing the expression tree, the parameter in the MemberExpression of the Java function is incorrect.
In my example, the parameter in the MemberExpression is P0, while it should be P1 which is the String parameter used for the startsWith method. In the full LambdaExpression that String is also marked as P1. P0 is the integer and has nothing to do with the startsWith check. Could you help me with this?

tree

My feeling is that you mess between parameters and arguments. See a very good explanation on Stack Overflow.
You can always look on each Expression's toString() method. Both, to see if it makes sense and also as a reference for a handler code. As you see, at each level it correctly re-builds the inner expression.

But that still doesn't explain why the parameter in my example is P0 and not P1.

If you refer to parameter collection in your last comment - they are formal parameters for the MemberExpression (method signature). They always go from 0 to N. They are not interesting for transformers (like you). I use them internally for argument verification when constructing the InvocationExpression (see its constructor).
You should use arguments, since this collections contains the actual values passed to the method. See InvocationExpression.toString() for an example.

I see. Thanks a lot, that helps.