From 56c1e99c2030a2de2e28b19b3f0c44e609449525 Mon Sep 17 00:00:00 2001 From: xzyfer Date: Mon, 26 Sep 2016 00:00:48 +1000 Subject: [PATCH] Don't apply unary operations on colors Spec sass/sass-spec#930 Fixes #2140 --- src/eval.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/eval.cpp b/src/eval.cpp index 7df3953425..8ba5007dc3 100644 --- a/src/eval.cpp +++ b/src/eval.cpp @@ -759,7 +759,20 @@ namespace Sass { if (operand->concrete_type() == Expression::NULL_VAL && dynamic_cast(u->operand())) { u->operand(SASS_MEMORY_NEW(ctx.mem, String_Quoted, u->pstate(), "")); } - else u->operand(operand); + // Never apply unary opertions on colors @see #2140 + else if (operand->concrete_type() == Expression::COLOR) { + Color* c = dynamic_cast(operand); + + // Use the color name if this was eval with one + if (c->disp().length() > 0) { + operand = SASS_MEMORY_NEW(ctx.mem, String_Constant, operand->pstate(), c->disp()); + u->operand(operand); + } + } + else { + u->operand(operand); + } + String_Constant* result = SASS_MEMORY_NEW(ctx.mem, String_Quoted, u->pstate(), u->inspect());