@@ -258,25 +258,35 @@ namespace Sass {
258
258
}
259
259
}
260
260
else {
261
+ bool arglist = list->is_arglist ();
261
262
for (size_t i = 0 , L = list->length (); i < L; ++i) {
262
- List* variable = 0 ;
263
- if ((*list)[i]->concrete_type () != Expression::LIST || variables.size () == 1 ) {
264
- variable = new (ctx.mem ) List ((*list)[i]->pstate (), 1 , SASS_COMMA);
265
- *variable << (*list)[i];
266
- }
267
- else {
268
- variable = static_cast <List*>((*list)[i]);
269
- }
270
- for (size_t j = 0 , K = variables.size (); j < K; ++j) {
271
- if (j < variable->length ()) {
272
- env->set_local (variables[j], (*variable)[j]);
263
+ Expression* e = (*list)[i];
264
+ // unwrap value if the expression is an argument
265
+ if (Argument* arg = dynamic_cast <Argument*>(e)) e = arg->value ();
266
+ // check if we got passed a list of args (investigate)
267
+ if (List* scalars = dynamic_cast <List*>(e)) {
268
+ if (variables.size () == 1 ) {
269
+ Expression* var = scalars;
270
+ if (arglist) var = (*scalars)[0 ];
271
+ env->set_local (variables[0 ], var);
272
+ } else {
273
+ for (size_t j = 0 , K = variables.size (); j < K; ++j) {
274
+ Expression* res = j >= scalars->length ()
275
+ ? new (ctx.mem ) Null (expr->pstate ())
276
+ : (*scalars)[j];
277
+ env->set_local (variables[j], res);
278
+ }
273
279
}
274
- else {
275
- env->set_local (variables[j], new (ctx.mem ) Null (expr->pstate ()));
280
+ } else {
281
+ if (variables.size () > 0 ) {
282
+ env->set_local (variables[0 ], e);
283
+ for (size_t j = 1 , K = variables.size (); j < K; ++j) {
284
+ Expression* res = new (ctx.mem ) Null (expr->pstate ());
285
+ env->set_local (variables[j], res);
286
+ }
276
287
}
277
- val = body->perform (this );
278
- if (val) break ;
279
288
}
289
+ val = body->perform (this );
280
290
if (val) break ;
281
291
}
282
292
}
@@ -395,7 +405,7 @@ namespace Sass {
395
405
std::string cwd (ctx.get_cwd ());
396
406
std::string result (unquote (message->perform (&to_string)));
397
407
std::string rel_path (Sass::File::resolve_relative_path (d->pstate ().path , cwd, cwd));
398
- std::cerr << rel_path << " :" << d->pstate ().line << " : " << " DEBUG: " << result;
408
+ std::cerr << rel_path << " :" << d->pstate ().line + 1 << " DEBUG: " << result;
399
409
std::cerr << std::endl;
400
410
return 0 ;
401
411
}
0 commit comments