diff --git a/include/chaiscript/dispatchkit/any.hpp b/include/chaiscript/dispatchkit/any.hpp index a9e31594..f8f94f26 100644 --- a/include/chaiscript/dispatchkit/any.hpp +++ b/include/chaiscript/dispatchkit/any.hpp @@ -84,7 +84,7 @@ namespace chaiscript { // construct/copy/destruct constexpr Any() noexcept = default; Any(Any &&) noexcept = default; - Any &operator=(Any &&t_any) noexcept = default; + Any &operator=(Any &&t_any) = default; Any(const Any &t_any) : m_data(t_any.empty() ? nullptr : t_any.m_data->clone()) @@ -93,7 +93,7 @@ namespace chaiscript { template>>> - explicit Any(ValueType &&t_value) noexcept(is_nothrow_forward_constructible_v>) + explicit Any(ValueType &&t_value) : m_data(std::make_unique>>(std::forward(t_value))) { } diff --git a/include/chaiscript/dispatchkit/dispatchkit.hpp b/include/chaiscript/dispatchkit/dispatchkit.hpp index 4f338cee..6e39aff4 100644 --- a/include/chaiscript/dispatchkit/dispatchkit.hpp +++ b/include/chaiscript/dispatchkit/dispatchkit.hpp @@ -1053,7 +1053,7 @@ namespace chaiscript tmp_params.insert(tmp_params.begin() + 1, var(t_name)); return do_attribute_call(2, Function_Params(tmp_params), functions, t_conversions); } else { - std::array p{params[0], var(t_name), var(std::vector(params.begin()+1, params.end()))}; + std::array p{params[0], var(t_name), var(std::vector(params.begin()+1, params.end()))}; return dispatch::dispatch(functions, Function_Params{p}, t_conversions); } } catch (const dispatch::option_explicit_set &e) { @@ -1077,7 +1077,7 @@ namespace chaiscript - Boxed_Value call_function(const std::string_view &t_name, std::atomic_uint_fast32_t &t_loc, Function_Params params, + Boxed_Value call_function(const std::string_view &t_name, std::atomic_uint_fast32_t &t_loc, const Function_Params ¶ms, const Type_Conversions_State &t_conversions) const { uint_fast32_t loc = t_loc; diff --git a/include/chaiscript/language/chaiscript_eval.hpp b/include/chaiscript/language/chaiscript_eval.hpp index a99c4ebb..781615c9 100644 --- a/include/chaiscript/language/chaiscript_eval.hpp +++ b/include/chaiscript/language/chaiscript_eval.hpp @@ -428,10 +428,20 @@ namespace chaiscript Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override { chaiscript::eval::detail::Function_Push_Pop fpp(t_ss); - std::array params{this->children[0]->eval(t_ss), this->children[1]->eval(t_ss)}; + auto params = [&](){ + // The RHS *must* be evaluated before the LHS + // consider `var range = range(x)` + // if we declare the variable in scope first, then the name lookup fails + // for the RHS + auto rhs = this->children[1]->eval(t_ss); + auto lhs = this->children[0]->eval(t_ss); + std::array p{std::move(lhs), std::move(rhs)}; + return p; + }(); + if (m_oper != Operators::Opers::invalid && params[0].get_type_info().is_arithmetic() && - params[0].get_type_info().is_arithmetic()) + params[1].get_type_info().is_arithmetic()) { try { return Boxed_Number::do_oper(m_oper, params[0], params[1]); @@ -452,7 +462,7 @@ namespace chaiscript && this->children[0]->children[0]->identifier == AST_Node_Type::Reference) ) ) - + { /// \todo This does not handle the case of an unassigned reference variable /// being assigned outside of its declaration