Skip to content

Commit 3b0feb9

Browse files
committed
Merge pull request #785 from xzyfer/fix/map-list-coersion
Maps in each with one vairable should coerce into a list
2 parents b3ff547 + a0e3382 commit 3b0feb9

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

eval.cpp

+12-2
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,18 @@ namespace Sass {
141141

142142
if (map) {
143143
for (auto key : map->keys()) {
144-
(*env)[variables[0]] = key;
145-
(*env)[variables[1]] = map->at(key);
144+
Expression* value = map->at(key);
145+
146+
if (variables.size() == 1) {
147+
List* variable = new (ctx.mem) List(map->path(), map->position(), 2, List::SPACE);
148+
*variable << key;
149+
*variable << value;
150+
(*env)[variables[0]] = variable;
151+
} else {
152+
(*env)[variables[0]] = key;
153+
(*env)[variables[1]] = value;
154+
}
155+
146156
val = body->perform(this);
147157
if (val) break;
148158
}

expand.cpp

+12-2
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,18 @@ namespace Sass {
272272

273273
if (map) {
274274
for (auto key : map->keys()) {
275-
(*env)[variables[0]] = key->perform(eval->with(env, backtrace));
276-
(*env)[variables[1]] = map->at(key)->perform(eval->with(env, backtrace));
275+
Expression* k = key->perform(eval->with(env, backtrace));
276+
Expression* v = map->at(key)->perform(eval->with(env, backtrace));
277+
278+
if (variables.size() == 1) {
279+
List* variable = new (ctx.mem) List(map->path(), map->position(), 2, List::SPACE);
280+
*variable << k;
281+
*variable << v;
282+
(*env)[variables[0]] = variable;
283+
} else {
284+
(*env)[variables[0]] = k;
285+
(*env)[variables[1]] = v;
286+
}
277287
append_block(body);
278288
}
279289
}

0 commit comments

Comments
 (0)