From c42fdc5ee772a18b178bb12d93e5f3d19eab23c0 Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Sun, 24 May 2020 10:47:11 -0400 Subject: [PATCH] remove unwrap when nothing after / --- src/utils/read_until.rs | 4 ++-- tests/if.rs | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/utils/read_until.rs b/src/utils/read_until.rs index 8fb213b..55f855d 100644 --- a/src/utils/read_until.rs +++ b/src/utils/read_until.rs @@ -21,8 +21,8 @@ pub(crate) fn read_until_open_curly_brace>( '}' => n -= 1, '/' => { let next = toks.next().unwrap(); - match toks.peek().unwrap().kind { - '/' => read_until_newline(toks), + match toks.peek() { + Some(Token { kind: '/', .. }) => read_until_newline(toks), _ => t.push(next), }; continue; diff --git a/tests/if.rs b/tests/if.rs index ca058b1..13f8add 100644 --- a/tests/if.rs +++ b/tests/if.rs @@ -129,3 +129,4 @@ error!( error!(unclosed_dbl_quote, "@if true \" {}", "Error: Expected \"."); error!(unclosed_sgl_quote, "@if true ' {}", "Error: Expected '."); error!(unclosed_call_args, "@if a({}", "Error: expected \")\"."); +error!(nothing_after_div, "@if a/", "Error: Expected expression.");