From d603d067d50898235edd62f395e93feb0f50a926 Mon Sep 17 00:00:00 2001 From: ochafik Date: Tue, 28 Jan 2025 23:49:04 +0000 Subject: [PATCH] sync: minja --- common/minja.hpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/common/minja.hpp b/common/minja.hpp index 604e61389..dd0ae6ccb 100644 --- a/common/minja.hpp +++ b/common/minja.hpp @@ -1270,6 +1270,11 @@ public: } auto r = right->evaluate(context); + if (op != Op::Eq && op != Op::Ne) { + if (r.is_null() || (l.is_null() && (op != Op::In && op != Op::NotIn))) { + throw std::runtime_error("unsupported operand type(s)"); + } + } switch (op) { case Op::StrConcat: return l.to_str() + r.to_str(); case Op::Add: return l + r; @@ -2147,11 +2152,11 @@ private: } std::runtime_error unexpected(const TemplateToken & token) const { - return std::runtime_error("Unexpected " + TemplateToken::typeToString(token.type) + return std::runtime_error("Encountered unknown tag '" + TemplateToken::typeToString(token.type) + "'" + error_location_suffix(*template_str, token.location.pos)); } std::runtime_error unterminated(const TemplateToken & token) const { - return std::runtime_error("Unterminated " + TemplateToken::typeToString(token.type) + return std::runtime_error("Unexpected end of template. Jinja was looking for the following tags: '" + TemplateToken::typeToString(token.type) + "'" + error_location_suffix(*template_str, token.location.pos)); }