diff --git a/src/parse/variable.rs b/src/parse/variable.rs index a66fe1d..2321f91 100644 --- a/src/parse/variable.rs +++ b/src/parse/variable.rs @@ -123,7 +123,9 @@ impl<'a> Parser<'a> { } Some(..) | None => {} } - val_toks.push(self.toks.next().unwrap()); + if let Some(tok) = self.toks.next() { + val_toks.push(tok); + } } '{' => break, '}' => { diff --git a/tests/variables.rs b/tests/variables.rs index bad5ee6..b697a48 100644 --- a/tests/variables.rs +++ b/tests/variables.rs @@ -143,3 +143,7 @@ error!( invalid_escape, "$\\110000: red;", "Error: Invalid escape sequence." ); +error!( + nothing_after_hash_in_variable_decl, + "$color: #", "Error: Expected identifier." +);