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." +);