From a0e338231084dd712bd94b8e0fcdaf407dbfe844 Mon Sep 17 00:00:00 2001 From: xzyfer Date: Mon, 29 Dec 2014 16:35:47 +1100 Subject: [PATCH] Maps in each with one vairable should coerce into a list --- eval.cpp | 14 ++++++++++++-- expand.cpp | 14 ++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/eval.cpp b/eval.cpp index ffcd9515b4..1cd836afa2 100644 --- a/eval.cpp +++ b/eval.cpp @@ -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; } diff --git a/expand.cpp b/expand.cpp index b200e49672..832ca08a51 100644 --- a/expand.cpp +++ b/expand.cpp @@ -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); } }