Henri Biestro created JEXL-136:
----------------------------------

             Summary: Script calls within scripts may fail with number arguments
                 Key: JEXL-136
                 URL: https://issues.apache.org/jira/browse/JEXL-136
             Project: Commons JEXL
          Issue Type: Bug
    Affects Versions: 2.1.1
            Reporter: Henri Biestro
            Assignee: Henri Biestro
             Fix For: 2.1.2, 3.0


Jexl attempts to narrow arguments when solving function names; unfortunately,
this may cause issues when the function is a script and the argument type is 
expected to remain untouched.

The map key in the following code is an Integer; by calling the function fn01, 
the interpreter fails to find a method and retries after 'narrowing' the 
argument which becomes a Byte. The Byte is not equal to the Integer map key 
with the same value; the test fails.

{code}
       @Test
        public void test136() throws Exception {
            JexlEngine jexl = new Engine();
            JexlContext jc = new MapContext();
            JexlScript script;
            JexlExpression expr;
            Object result;

            script = jexl.createScript("var x = $TAB[idx]; return x;", "idx");
            jc.set("fn01", script);

            script = jexl.createScript("$TAB = { 1:11, 2:22, 3:33}; IDX=2;");
            script.execute(jc);

            expr = jexl.createExpression("fn01(IDX)");
            result = expr.evaluate(jc);
            assertEquals("EXPR01 result", 22, result);
        }
{code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to