Skip to content

Commit f1c9e06

Browse files
committed
Merge pull request #1131 from mgreter/bugfix/issue_1130
Allow empty rest arguments in varargs
2 parents 6796c86 + 120d8eb commit f1c9e06

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

bind.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,22 @@ namespace Sass {
2828
size_t ip = 0, LP = ps->length();
2929
size_t ia = 0, LA = as->length();
3030
while (ia < LA) {
31+
Argument* a = (*as)[ia];
3132
if (ip >= LP) {
33+
// skip empty rest arguments
34+
if (a->is_rest_argument()) {
35+
if (List* l = dynamic_cast<List*>(a->value())) {
36+
if (l->length() == 0) {
37+
++ ia; continue;
38+
}
39+
}
40+
}
3241
stringstream msg;
3342
msg << callee << " only takes " << LP << " arguments; "
3443
<< "given " << LA;
3544
error(msg.str(), as->pstate());
3645
}
3746
Parameter* p = (*ps)[ip];
38-
Argument* a = (*as)[ia];
3947

4048
// If the current parameter is the rest parameter, process and break the loop
4149
if (p->is_rest_parameter()) {

0 commit comments

Comments
 (0)