Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Inconsistent expression evaluation for nested expressions

Open
#1,260 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
68/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
java
Domain
compilers

Research direction

Start in src/main/java/com/hubspot/jinjava/el/ext/ExtendedParser.java around lines 305-316 and reproduce the four expressions from the issue. Compare parsing of the list literal inside the nested expression with parsing through the categories variable. Done means negation produces the same expected result in both forms.

Written by the indexing model from the issue text.

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 https://github.com/HubSpot/jinjava/blob/43bbea7e772a961316f575f26297f198eb3c655a/src/main/java/com/hubspot/jinjava/el/ext/ExtendedParser.java#L305-L316

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

Dominant language
Java
Stars
785
Forks
184
Avg merge
6d 22h
Merged PRs (30d)
1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from HubSpot/jinjava

All issues in HubSpot/jinjava

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.