Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/minja/minja.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1356,8 +1356,8 @@ class BinaryOpExpr : public Expression {
}

if (op == Op::And) {
if (!l.to_bool()) return Value(false);
return right->evaluate(context).to_bool();
if (!l.to_bool()) return l;
return right->evaluate(context);
} else if (op == Op::Or) {
if (l.to_bool()) return l;
return right->evaluate(context);
Expand Down
3 changes: 3 additions & 0 deletions tests/test-syntax.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,9 @@ TEST(SyntaxTest, SimpleCases) {
EXPECT_EQ(
"2; ; 10",
render(R"({{ {1: 2}.get(1) }}; {{ {}.get(1) or '' }}; {{ {}.get(1, 10) }})", {}, {}));
EXPECT_EQ(
"def; ; A; B",
render(R"({{ 'abc' and 'def' }}; {{ '' and 'x' }}; {{ (true and 'A') or 'B' }}; {{ (false and 'A') or 'B' }})", {}, {}));
EXPECT_EQ(
R"(1,1.2,"a",true,true,false,false,null,[],[1],[1, 2],{},{"a": 1},{"1": "b"},)",
render(R"(
Expand Down