You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Henri Biestro (JIRA)" <ji...@apache.org> on 2011/07/11 14:27:59 UTC

[jira] [Issue Comment Edited] (JEXL-113) Dot notation behaves unexpectedly with null values

    [ https://issues.apache.org/jira/browse/JEXL-113?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13063263#comment-13063263 ] 

Henri Biestro edited comment on JEXL-113 at 7/11/11 12:27 PM:
--------------------------------------------------------------

The reason for the Set<List<String>> would be to track both 'dot' operators and 'bracketed' expressions since they dont differ in evaluation. Every 'dot' expr can be rewritten as a 'bracketed' expr (not the opposite because of restrictions in allowed characters for identifiers).

Anyway, reusing your example:
a + b.c + d['e']['f'] would return { {"a"}, {"b", "c"}, {"d", "e", "f"} }
However, a + b[func()] would only return { {"a"}, {"b"} }

Cheers,
Henri

      was (Author: henrib):
    The reason for the Set<List<String>> would be to track both 'dot' operators and 'bracketed' expressions since they dont differ in evaluation. Every 'dot' expr can be rewritten as a 'bracketed' expr (not the opposite because of restrictions in allowed characters for identifiers).

Anyway, reusing your example:
a + b.c + d[e][f] would return { {"a"}, {"b", "c"}, {"d", "e", "f"} }
However, a + b[func()] would only return { {"a"}, {"b"} }

Cheers,
Henri
  
> Dot notation behaves unexpectedly with null values
> --------------------------------------------------
>
>                 Key: JEXL-113
>                 URL: https://issues.apache.org/jira/browse/JEXL-113
>             Project: Commons JEXL
>          Issue Type: Bug
>    Affects Versions: 2.0.1
>         Environment: JDK 1.6
>            Reporter: Max Tardiveau
>
> When a variable of the form a.b is evaluated, the context is asked first for the value of a. That value is then asked for the value of b.
> So far, so good: this is exactly what you'd expect from the dot operator.
> But if the value of b is null, the context is then asked for the value of a.b, in other words the dot operator is ignored and "a.b" is considered to be a single variable.
> This is at best confusing. Granted, this can be avoided with the a['b'] notation, but that's clumsy.
> I assume this is an attempt to support both the dot operator and ant-style variables. I don't think you can have both and remain sane.
> Suggestion: either document this behavior, or make it an option. My vote would be to just use the value returned, even if it's null. Either dot is an operator, or it's not. Perhaps make that configurable?
> Thanks!

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira