Skip to content

Commit d603d06

Browse files
author
ochafik
committed
sync: minja
1 parent 4f25755 commit d603d06

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

common/minja.hpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,6 +1270,11 @@ class BinaryOpExpr : public Expression {
12701270
}
12711271

12721272
auto r = right->evaluate(context);
1273+
if (op != Op::Eq && op != Op::Ne) {
1274+
if (r.is_null() || (l.is_null() && (op != Op::In && op != Op::NotIn))) {
1275+
throw std::runtime_error("unsupported operand type(s)");
1276+
}
1277+
}
12731278
switch (op) {
12741279
case Op::StrConcat: return l.to_str() + r.to_str();
12751280
case Op::Add: return l + r;
@@ -2147,11 +2152,11 @@ class Parser {
21472152
}
21482153

21492154
std::runtime_error unexpected(const TemplateToken & token) const {
2150-
return std::runtime_error("Unexpected " + TemplateToken::typeToString(token.type)
2155+
return std::runtime_error("Encountered unknown tag '" + TemplateToken::typeToString(token.type) + "'"
21512156
+ error_location_suffix(*template_str, token.location.pos));
21522157
}
21532158
std::runtime_error unterminated(const TemplateToken & token) const {
2154-
return std::runtime_error("Unterminated " + TemplateToken::typeToString(token.type)
2159+
return std::runtime_error("Unexpected end of template. Jinja was looking for the following tags: '" + TemplateToken::typeToString(token.type) + "'"
21552160
+ error_location_suffix(*template_str, token.location.pos));
21562161
}
21572162

0 commit comments

Comments
 (0)