diff --git a/src/value/parse.rs b/src/value/parse.rs index 354055f..b5c52bb 100644 --- a/src/value/parse.rs +++ b/src/value/parse.rs @@ -722,14 +722,16 @@ impl Value { }) } '#' => { - if let Ok(s) = Self::ident(toks, scope, super_selector) { - s - } else { - IntermediateValue::Value(match parse_hex(toks, scope, super_selector, span) { - Ok(v) => v, - Err(e) => return Some(Err(e)), - }) + if let Some(Token { kind: '{', .. }) = toks.peek_forward(1) { + toks.reset_view(); + return Some(Self::ident(toks, scope, super_selector)); } + toks.reset_view(); + toks.next(); + IntermediateValue::Value(match parse_hex(toks, scope, super_selector, span) { + Ok(v) => v, + Err(e) => return Some(Err(e)), + }) } q @ '"' | q @ '\'' => { let span_start = toks.next().unwrap().pos(); diff --git a/tests/interpolation.rs b/tests/interpolation.rs index 15bd94c..3b11a0b 100644 --- a/tests/interpolation.rs +++ b/tests/interpolation.rs @@ -73,3 +73,7 @@ test!( "$f: foo;\na {\n color: #{$f}(a, 1+2, c);\n}\n", "a {\n color: foo(a, 3, c);\n}\n" ); +error!( + error_message_when_at_start_of_value, + "a {\n color: #{2px*5px};\n}\n", "Error: 10px*px isn't a valid CSS value." +);