diff --git a/src/bind.cpp b/src/bind.cpp index fdae1fea6..c6ad88bd8 100644 --- a/src/bind.cpp +++ b/src/bind.cpp @@ -10,7 +10,7 @@ namespace Sass { - void bind(std::string type, std::string name, Parameters_Obj ps, Arguments_Obj as, Env* env, Eval* eval) + void bind(std::string type, std::string name, Parameters_Obj ps, Arguments_Obj as, Env* env, Eval* eval, Backtraces& traces) { std::string callee(type + " " + name); @@ -54,7 +54,7 @@ namespace Sass { std::stringstream msg; msg << "wrong number of arguments (" << LA << " for " << LP << ")"; msg << " for `" << name << "'"; - return error(msg.str(), as->pstate(), eval->exp.traces); + return error(msg.str(), as->pstate(), traces); } Parameter_Obj p = ps->at(ip); @@ -107,8 +107,8 @@ namespace Sass { false, false)); } else { - eval->exp.traces.push_back(Backtrace(key->pstate())); - throw Exception::InvalidVarKwdType(key->pstate(), eval->exp.traces, key->inspect(), a); + traces.push_back(Backtrace(key->pstate())); + throw Exception::InvalidVarKwdType(key->pstate(), traces, key->inspect(), a); } } @@ -222,15 +222,15 @@ namespace Sass { for (auto key : argmap->keys()) { String_Constant_Ptr val = Cast(key); if (val == NULL) { - eval->exp.traces.push_back(Backtrace(key->pstate())); - throw Exception::InvalidVarKwdType(key->pstate(), eval->exp.traces, key->inspect(), a); + traces.push_back(Backtrace(key->pstate())); + throw Exception::InvalidVarKwdType(key->pstate(), traces, key->inspect(), a); } std::string param = "$" + unquote(val->value()); if (!param_map.count(param)) { std::stringstream msg; msg << callee << " has no parameter named " << param; - error(msg.str(), a->pstate(), eval->exp.traces); + error(msg.str(), a->pstate(), traces); } env->local_frame()[param] = argmap->at(key); } @@ -245,7 +245,7 @@ namespace Sass { std::stringstream msg; msg << "parameter " << p->name() << " provided more than once in call to " << callee; - error(msg.str(), a->pstate(), eval->exp.traces); + error(msg.str(), a->pstate(), traces); } // ordinal arg -- bind it to the next param env->local_frame()[p->name()] = a->value(); @@ -259,7 +259,7 @@ namespace Sass { } else { std::stringstream msg; msg << callee << " has no parameter named " << a->name(); - error(msg.str(), a->pstate(), eval->exp.traces); + error(msg.str(), a->pstate(), traces); } } if (param_map[a->name()]) { @@ -267,14 +267,14 @@ namespace Sass { std::stringstream msg; msg << "argument " << a->name() << " of " << callee << "cannot be used as named argument"; - error(msg.str(), a->pstate(), eval->exp.traces); + error(msg.str(), a->pstate(), traces); } } if (env->has_local(a->name())) { std::stringstream msg; msg << "parameter " << p->name() << "provided more than once in call to " << callee; - error(msg.str(), a->pstate(), eval->exp.traces); + error(msg.str(), a->pstate(), traces); } env->local_frame()[a->name()] = a->value(); } @@ -299,7 +299,7 @@ namespace Sass { } else { // param is unbound and has no default value -- error - throw Exception::MissingArgument(as->pstate(), eval->exp.traces, name, leftover->name(), type); + throw Exception::MissingArgument(as->pstate(), traces, name, leftover->name(), type); } } } diff --git a/src/bind.hpp b/src/bind.hpp index 9e9e0ec4e..7ad87f8f8 100644 --- a/src/bind.hpp +++ b/src/bind.hpp @@ -2,12 +2,13 @@ #define SASS_BIND_H #include +#include "backtrace.hpp" #include "environment.hpp" #include "ast_fwd_decl.hpp" namespace Sass { - void bind(std::string type, std::string name, Parameters_Obj, Arguments_Obj, Env*, Eval*); + void bind(std::string type, std::string name, Parameters_Obj, Arguments_Obj, Env*, Eval*, Backtraces traces); } #endif diff --git a/src/eval.cpp b/src/eval.cpp index 4985e5210..77f948004 100644 --- a/src/eval.cpp +++ b/src/eval.cpp @@ -1005,7 +1005,7 @@ namespace Sass { exp.env_stack.push_back(&fn_env); if (func || body) { - bind(std::string("Function"), c->name(), params, args, &fn_env, this); + bind(std::string("Function"), c->name(), params, args, &fn_env, this, traces); std::string msg(", in function `" + c->name() + "`"); traces.push_back(Backtrace(c->pstate(), msg)); ctx.callee_stack.push_back({ @@ -1045,7 +1045,7 @@ namespace Sass { // populates env with default values for params std::string ff(c->name()); - bind(std::string("Function"), c->name(), params, args, &fn_env, this); + bind(std::string("Function"), c->name(), params, args, &fn_env, this, traces); std::string msg(", in function `" + c->name() + "`"); traces.push_back(Backtrace(c->pstate(), msg)); ctx.callee_stack.push_back({ diff --git a/src/expand.cpp b/src/expand.cpp index 1987c4907..3ff8b728d 100644 --- a/src/expand.cpp +++ b/src/expand.cpp @@ -740,7 +740,7 @@ namespace Sass { new_env.local_frame()["@content[m]"] = thunk; } - bind(std::string("Mixin"), c->name(), params, args, &new_env, &eval); + bind(std::string("Mixin"), c->name(), params, args, &new_env, &eval, traces); Block_Obj trace_block = SASS_MEMORY_NEW(Block, c->pstate()); Trace_Obj trace = SASS_MEMORY_NEW(Trace, c->pstate(), c->name(), trace_block);