Skip to content

Commit

Permalink
Fix calling overloaded stub functions with rest arguments
Browse files Browse the repository at this point in the history
Fixes sass#2205
  • Loading branch information
mgreter committed Oct 20, 2016
1 parent efa6496 commit b8cf94c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/eval.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -827,8 +827,15 @@ namespace Sass {

if (def->is_overload_stub()) {
std::stringstream ss;
ss << full_name
<< args->length();
size_t L = args->length();
// account for rest arguments
if (args->has_rest_argument() && args->length() > 0) {
// get the rest arguments list
List* rest = dynamic_cast<List*>(args->last()->value());
// arguments before rest argument plus rest
if (rest) L += rest->length() - 1;
}
ss << full_name << L;
full_name = ss.str();
std::string resolved_name(full_name);
if (!env->has(resolved_name)) error("overloaded function `" + std::string(c->name()) + "` given wrong number of arguments", c->pstate());
Expand Down

0 comments on commit b8cf94c

Please # to comment.