From 4fdd1ce69a57c6b7830aa2236e8a964a51a582f4 Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Sun, 26 Jan 2020 10:53:52 -0500 Subject: [PATCH] Add error message for toplevel `&` --- src/lib.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 061ead6..c37ed3e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -310,7 +310,7 @@ struct StyleSheetParser<'a> { impl<'a> StyleSheetParser<'a> { fn parse_toplevel(mut self) -> SassResult<(Vec, Scope)> { let mut rules: Vec = Vec::new(); - while let Some(Token { kind, .. }) = self.lexer.peek() { + while let Some(Token { kind, pos }) = self.lexer.peek() { match kind { TokenKind::Ident(_) | TokenKind::Attribute(_) @@ -422,6 +422,9 @@ impl<'a> StyleSheetParser<'a> { } } } + TokenKind::Symbol(Symbol::BitAnd) => { + return Err(SassError::new("Base-level rules cannot contain the parent-selector-referencing character '&'.", pos.clone())) + } _ => match self.lexer.next() { Some(Token { pos, .. }) => self.error(pos, "unexpected toplevel token"), _ => unsafe { std::hint::unreachable_unchecked() },