jinja : support noncall test statements with arg (#29443)

* support noncall test statements with arg

* add tests
This commit is contained in:
Sigbjørn Skjæret authored and GitHub committed 2026-09-26 08:56:48 +02:00
1 parent 965f89794f
commit a1de614ba3
2 files changed
+24 -5

No files matched your search

+9 -2
View File
@@ -429,8 +429,15 @@ private:
bool negate = false;
if (is_identifier("not")) { ++current; negate = true; }
auto test_id = parse_primary_expression();
// FIXME: tests can also be expressed like this: if x is eq 3
if (is(token::open_paren)) test_id = parse_call_expression(std::move(test_id));
if (is(token::open_paren)) {
test_id = parse_call_expression(std::move(test_id));
} else if (is(token::numeric_literal) || is(token::string_literal) || is(token::open_curly_bracket) || is(token::open_square_bracket) ||
(is(token::identifier) && !is_identifier("and") && !is_identifier("or") && !is_identifier("else"))) {
size_t call_pos = current;
statements args;
args.push_back(std::move(parse_unary_expression()));
test_id = mk_stmt<call_expression>(call_pos, std::move(test_id), std::move(args));
}
operand = mk_stmt<test_expression>(start_pos, std::move(operand), negate, std::move(test_id));
}
return operand;