From 725dc1bf2dec9b5c58b341a4f413144804ddb8f2 Mon Sep 17 00:00:00 2001 From: Piotr Wilkin Date: Tue, 3 Feb 2026 19:07:01 +0100 Subject: [PATCH] Fix minor regressions, add [[noreturn]] attrib --- common/jinja/value.cpp | 16 ---------------- common/jinja/value.h | 33 +++++++++++++++++---------------- 2 files changed, 17 insertions(+), 32 deletions(-) diff --git a/common/jinja/value.cpp b/common/jinja/value.cpp index 17d7eae764..38da1df6d3 100644 --- a/common/jinja/value.cpp +++ b/common/jinja/value.cpp @@ -428,22 +428,6 @@ const func_builtins & global_builtins() { bool res = it != builtins.end(); return mk_val(res); }}, - {"test_is_in", [](const func_args & args) -> value { - args.ensure_count(2, 2); - value val_needle = args.get_pos(0); - value val_haystack = args.get_pos(1); - const auto & haystack = is_val(val_haystack) ? val_haystack->as_array() : std::vector(1, val_haystack); - for (auto it = haystack.cbegin(); it != haystack.cend(); it++) { - if ((*it)->type() == val_needle->type()) { - if (is_val(val_haystack) ? - (*it)->as_string().str().find(val_needle->as_string().str()) != std::string::npos : - value_compare(*it, val_needle, value_compare_op::eq)) { - return mk_val(true); - } - } - } - return mk_val(false); - }}, {"test_is_sameas", [](const func_args & args) -> value { // Check if an object points to the same memory address as another object (void)args; diff --git a/common/jinja/value.h b/common/jinja/value.h index a2f92d2c69..a86f0f0587 100644 --- a/common/jinja/value.h +++ b/common/jinja/value.h @@ -13,6 +13,7 @@ #include #include #include +#include namespace jinja { @@ -126,27 +127,27 @@ struct value_t { // Note: only for debugging and error reporting purposes virtual std::string type() const { return ""; } - virtual int64_t as_int() const { throw std::runtime_error(type() + " is not an int value"); } - virtual double as_float() const { throw std::runtime_error(type() + " is not a float value"); } - virtual string as_string() const { throw std::runtime_error(type() + " is not a string value"); } - virtual bool as_bool() const { throw std::runtime_error(type() + " is not a bool value"); } - virtual const std::vector & as_array() const { throw std::runtime_error(type() + " is not an array value"); } - virtual const std::vector> & as_ordered_object() const { throw std::runtime_error(type() + " is not an object value"); } - virtual value invoke(const func_args &) const { throw std::runtime_error(type() + " is not a function value"); } + [[noreturn]] virtual int64_t as_int() const { throw std::runtime_error(type() + " is not an int value"); } + [[noreturn]] virtual double as_float() const { throw std::runtime_error(type() + " is not a float value"); } + [[noreturn]] virtual string as_string() const { throw std::runtime_error(type() + " is not a string value"); } + [[noreturn]] virtual bool as_bool() const { throw std::runtime_error(type() + " is not a bool value"); } + [[noreturn]] virtual const std::vector & as_array() const { throw std::runtime_error(type() + " is not an array value"); } + [[noreturn]] virtual const std::vector> & as_ordered_object() const { throw std::runtime_error(type() + " is not an object value"); } + [[noreturn]] virtual value invoke(const func_args &) const { throw std::runtime_error(type() + " is not a function value"); } virtual bool is_none() const { return false; } virtual bool is_undefined() const { return false; } - virtual const func_builtins & get_builtins() const { + [[noreturn]] virtual const func_builtins & get_builtins() const { throw std::runtime_error("No builtins available for type " + type()); } - virtual bool has_key(const value &) { throw std::runtime_error(type() + " is not an object value"); } - virtual void insert(const value & /* key */, const value & /* val */) { throw std::runtime_error(type() + " is not an object value"); } - virtual value & at(const value & /* key */, value & /* default_val */) { throw std::runtime_error(type() + " is not an object value"); } - virtual value & at(const value & /* key */) { throw std::runtime_error(type() + " is not an object value"); } - virtual value & at(const std::string & /* key */, value & /* default_val */) { throw std::runtime_error(type() + " is not an object value"); } - virtual value & at(const std::string & /* key */) { throw std::runtime_error(type() + " is not an object value"); } - virtual value & at(int64_t /* idx */, value & /* default_val */) { throw std::runtime_error(type() + " is not an array value"); } - virtual value & at(int64_t /* idx */) { throw std::runtime_error(type() + " is not an array value"); } + [[noreturn]] virtual bool has_key(const value &) { throw std::runtime_error(type() + " is not an object value"); } + [[noreturn]] virtual void insert(const value & /* key */, const value & /* val */) { throw std::runtime_error(type() + " is not an object value"); } + [[noreturn]] virtual value & at(const value & /* key */, value & /* default_val */) { throw std::runtime_error(type() + " is not an object value"); } + [[noreturn]] virtual value & at(const value & /* key */) { throw std::runtime_error(type() + " is not an object value"); } + [[noreturn]] virtual value & at(const std::string & /* key */, value & /* default_val */) { throw std::runtime_error(type() + " is not an object value"); } + [[noreturn]] virtual value & at(const std::string & /* key */) { throw std::runtime_error(type() + " is not an object value"); } + [[noreturn]] virtual value & at(int64_t /* idx */, value & /* default_val */) { throw std::runtime_error(type() + " is not an array value"); } + [[noreturn]] virtual value & at(int64_t /* idx */) { throw std::runtime_error(type() + " is not an array value"); } virtual bool is_numeric() const { return false; } virtual bool is_hashable() const { return false; }