Skip to content

Commit

Permalink
Merge pull request #785 from xzyfer/fix/map-list-coersion
Browse files Browse the repository at this point in the history
Maps in each with one vairable should coerce into a list
  • Loading branch information
xzyfer committed Dec 29, 2014
2 parents b3ff547 + a0e3382 commit 3b0feb9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
14 changes: 12 additions & 2 deletions eval.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,18 @@ namespace Sass {

if (map) {
for (auto key : map->keys()) {
(*env)[variables[0]] = key;
(*env)[variables[1]] = map->at(key);
Expression* value = map->at(key);

if (variables.size() == 1) {
List* variable = new (ctx.mem) List(map->path(), map->position(), 2, List::SPACE);
*variable << key;
*variable << value;
(*env)[variables[0]] = variable;
} else {
(*env)[variables[0]] = key;
(*env)[variables[1]] = value;
}

val = body->perform(this);
if (val) break;
}
Expand Down
14 changes: 12 additions & 2 deletions expand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,18 @@ namespace Sass {

if (map) {
for (auto key : map->keys()) {
(*env)[variables[0]] = key->perform(eval->with(env, backtrace));
(*env)[variables[1]] = map->at(key)->perform(eval->with(env, backtrace));
Expression* k = key->perform(eval->with(env, backtrace));
Expression* v = map->at(key)->perform(eval->with(env, backtrace));

if (variables.size() == 1) {
List* variable = new (ctx.mem) List(map->path(), map->position(), 2, List::SPACE);
*variable << k;
*variable << v;
(*env)[variables[0]] = variable;
} else {
(*env)[variables[0]] = k;
(*env)[variables[1]] = v;
}
append_block(body);
}
}
Expand Down

0 comments on commit 3b0feb9

Please sign in to comment.