From de8e7048d8b09efa4adbc5cf11e8b303880f9818 Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Thu, 18 Jun 2020 01:13:23 -0400 Subject: [PATCH] remove unwrap from variable value parsing --- src/parse/variable.rs | 4 +++- tests/variables.rs | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) 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." +);