-
Notifications
You must be signed in to change notification settings - Fork 174
Open
Description
Consider following case:
{{ "c" in ["a", "b"] }} // outputs false
{{ !("c" in ["a", "b"]) }} // also outputs false
{% set categories = ["a", "b"] %}
{{ "c" in categories }} // outputs false
{{ !("c" in categories) }} // correctly outputs true
I'd expect expression evaluation to behave the same both for versions - with or without variables used, but it does not.
I've tracked this down to what i believe is a bug in parser
jinjava/src/main/java/com/hubspot/jinjava/el/ext/ExtendedParser.java
Lines 305 to 316 in 43bbea7
| while (s != Symbol.EOF && (depth > 0 || s != Symbol.RPAREN)) { | |
| if (s == LPAREN || s == LBRACK) { | |
| depth++; | |
| } else if (depth > 0 && (s == RPAREN || s == RBRACK)) { | |
| depth--; | |
| } else if (depth == 0) { | |
| if (s == Symbol.COMMA) { | |
| return createAstTuple(params()); | |
| } | |
| } | |
| s = lookahead(i++).getSymbol(); | |
| } |
If there is a coma between ( and ) token parser will interpret it as a tuple declaration and otherwise as nested expression. However this seems incorrect in the above case as I am not trying to declare a tuple, just using a list literal in nested comparison
mkp05 and jakubdakowicz-design
Metadata
Metadata
Assignees
Labels
No labels