From 618fa9ed864762e04485d47d4bd58bcceef90684 Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Thu, 2 Apr 2020 02:08:14 -0400 Subject: [PATCH] symbol after hash in value --- src/utils.rs | 2 +- src/value/parse.rs | 7 ++++++- tests/error.rs | 4 ++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/utils.rs b/src/utils.rs index 77d9db5..1b38823 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -368,7 +368,7 @@ pub(crate) fn eat_ident>( match tok.kind { '#' => { toks.next(); - if toks.peek().unwrap().kind == '{' { + if toks.peek().ok_or("Expected identifier.")?.kind == '{' { toks.next(); s.push_str(&parse_interpolation(toks, scope, super_selector)?.to_string()); } else { diff --git a/src/value/parse.rs b/src/value/parse.rs index ed75f44..94c955a 100644 --- a/src/value/parse.rs +++ b/src/value/parse.rs @@ -31,7 +31,12 @@ fn parse_hex>( super_selector: &Selector, ) -> SassResult { let mut s = String::with_capacity(8); - if toks.peek().unwrap().kind.is_ascii_digit() { + if toks + .peek() + .ok_or("Expected identifier.")? + .kind + .is_ascii_digit() + { while let Some(c) = toks.peek() { if !c.kind.is_ascii_hexdigit() || s.len() == 8 { break; diff --git a/tests/error.rs b/tests/error.rs index 328c5e4..9e74c5a 100644 --- a/tests/error.rs +++ b/tests/error.rs @@ -40,3 +40,7 @@ error!( close_paren_without_opening, "a {color: foo);}", "Error: expected \";\"." ); +error!( + symbol_after_hash, + "a {color: bar + #}ar;}", "Error: Expected identifier." +);