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

Support 'None' literal syntax (example template crashes / segfault / stack-buffer-overflow on "Load" today)

Open
#264 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
45/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
cpp
Domain
tooling

Research direction

Start in jinja2cpp/src/expression_parser.cpp, where the issue identifies the literal-expression handling and provides a candidate change. Load the supplied template example and verify that it produces the expected output for None and none without crashing, including the existing integer comparisons.

Written by the indexing model from the issue text.

Description

Appears to work in Python jinja2, and there's a Note that mentions it in this section in the docs.
https://jinja.palletsprojects.com/en/2.10.x/templates/#literals

Here's a template example that works in Python and crashes on "Load" today.

{% set foo = None %}
{% if foo != None %}
1
{% else %}
None
{% endif %}
{% set bar = 1 %}
{% if bar != None %}
1
{% else %}
None
{% endif %}
{% set baz = none %}
{% if baz != none %}
1
{% else %}
none
{% endif %}
{% set qux = 1 %}
{% if qux != none %}
1
{% else %}
none
{% endif %}

This code change seemed to do the trick for me and seems to produce the correct output and no longer crash.

diff --git a/jinja2cpp/src/expression_parser.cpp b/jinja2cpp/src/expression_parser.cpp
--- a/jinja2cpp/src/expression_parser.cpp
+++ b/jinja2cpp/src/expression_parser.cpp
@@ -326,6 +326,8 @@
         return std::make_shared<ConstantExpression>(InternalValue(true));
     case Token::False:
         return std::make_shared<ConstantExpression>(InternalValue(false));
+    case Token::None:
+        return std::make_shared<ConstantExpression>(InternalValue(EmptyValue()));
     case '(':
         valueRef = ParseBracedExpressionOrTuple(lexer);
         break;
Dominant language
C++
Stars
600
Forks
114
PR merge metrics
No merged PRs in 30d

Getting set up

We have not checked this project's setup files yet. Start from its README, and see our first-contribution guide for the general steps.

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 jinja2cpp/Jinja2Cpp

All issues in jinja2cpp/Jinja2Cpp

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.