From 9c74c7a48de7542c4dca93f49f98a85e163941fa Mon Sep 17 00:00:00 2001 From: Marcel Greter Date: Fri, 8 May 2015 01:56:20 +0200 Subject: [PATCH] Add base eval step for map keys while parsing Keys need to be immutable for the main structure, so we need to evaluate them while the map is being parsed. We may defer the map initialization into the eval step too. Fixes https://github.com/sass/libsass/issues/1169 --- parser.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/parser.cpp b/parser.cpp index acc1234e2c..c9db45c3ee 100644 --- a/parser.cpp +++ b/parser.cpp @@ -1010,6 +1010,16 @@ namespace Sass { { To_String to_string(&ctx); Expression* key = parse_list(); + if (String_Quoted* str = dynamic_cast(key)) { + if (!str->quote_mark() && !str->is_delayed()) { + if (ctx.names_to_colors.count(str->value())) { + Color* c = new (ctx.mem) Color(*ctx.names_to_colors[str->value()]); + c->pstate(str->pstate()); + c->disp(str->value()); + key = c; + } + } + } // it's not a map so return the lexed value as a list value if (!peek< exactly<':'> >()) @@ -1029,6 +1039,16 @@ namespace Sass { { break; } Expression* key = parse_list(); + if (String_Quoted* str = dynamic_cast(key)) { + if (!str->quote_mark() && !str->is_delayed()) { + if (ctx.names_to_colors.count(str->value())) { + Color* c = new (ctx.mem) Color(*ctx.names_to_colors[str->value()]); + c->pstate(str->pstate()); + c->disp(str->value()); + key = c; + } + } + } if (!(lex< exactly<':'> >())) { error("invalid syntax", pstate); }