From b93e3c6f2160b00acf606ae8130708b1bb1dd4a6 Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Thu, 2 Apr 2020 00:28:03 -0400 Subject: [PATCH] handle while with empty condition --- src/atrule/mod.rs | 5 +++++ tests/while.rs | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/src/atrule/mod.rs b/src/atrule/mod.rs index f054e71..b40ef56 100644 --- a/src/atrule/mod.rs +++ b/src/atrule/mod.rs @@ -317,6 +317,11 @@ impl AtRule { let mut stmts = Vec::new(); devour_whitespace(toks); let cond = read_until_open_curly_brace(toks); + + if cond.is_empty() { + return Err("Expected expression.".into()); + } + toks.next(); let scope = &mut scope.clone(); let body = read_until_closing_curly_brace(toks); diff --git a/tests/while.rs b/tests/while.rs index 8b4314b..f66e08e 100644 --- a/tests/while.rs +++ b/tests/while.rs @@ -23,3 +23,7 @@ test!( "@while false {\na {\n color: $b;\n }\n $b: $b + 1;\n}", "" ); +error!( + while_empty_condition, + "@while {}", "Error: Expected expression." +);