jinja: treat a null left operand of in as a plain lookup (#28620)

Templates that default an optional variable to none and then test its
membership in a map hit an error, while the same expression is a normal
lookup returning false in Jinja. The undefined counterpart of this case
was already handled just above.
This commit is contained in:
Pascal
2026-09-09 10:08:27 +03:00
committed by GitHub
parent df750f76bb
commit b31b71f3a0
2 changed files with 24 additions and 0 deletions
+18
View File
@@ -374,6 +374,24 @@ static void test_expressions(testing & t) {
"42"
);
test_template(t, "none in object",
"{{ x in {'low': 1, 'high': 2} }}",
{{"x", nullptr}},
"False"
);
test_template(t, "none not in object",
"{{ x not in {'low': 1, 'high': 2} }}",
{{"x", nullptr}},
"True"
);
test_template(t, "none in array",
"{{ x in [1, none, 3] }}",
{{"x", nullptr}},
"True"
);
test_template(t, "dot notation",
"{{ user.name }}",
{{"user", {{"name", "Bob"}}}},