Skip to content

Commit 9c74c7a

Browse files
committed
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 #1169
1 parent 66631c0 commit 9c74c7a

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

parser.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,6 +1010,16 @@ namespace Sass {
10101010
{
10111011
To_String to_string(&ctx);
10121012
Expression* key = parse_list();
1013+
if (String_Quoted* str = dynamic_cast<String_Quoted*>(key)) {
1014+
if (!str->quote_mark() && !str->is_delayed()) {
1015+
if (ctx.names_to_colors.count(str->value())) {
1016+
Color* c = new (ctx.mem) Color(*ctx.names_to_colors[str->value()]);
1017+
c->pstate(str->pstate());
1018+
c->disp(str->value());
1019+
key = c;
1020+
}
1021+
}
1022+
}
10131023

10141024
// it's not a map so return the lexed value as a list value
10151025
if (!peek< exactly<':'> >())
@@ -1029,6 +1039,16 @@ namespace Sass {
10291039
{ break; }
10301040

10311041
Expression* key = parse_list();
1042+
if (String_Quoted* str = dynamic_cast<String_Quoted*>(key)) {
1043+
if (!str->quote_mark() && !str->is_delayed()) {
1044+
if (ctx.names_to_colors.count(str->value())) {
1045+
Color* c = new (ctx.mem) Color(*ctx.names_to_colors[str->value()]);
1046+
c->pstate(str->pstate());
1047+
c->disp(str->value());
1048+
key = c;
1049+
}
1050+
}
1051+
}
10321052

10331053
if (!(lex< exactly<':'> >()))
10341054
{ error("invalid syntax", pstate); }

0 commit comments

Comments
 (0)