Properly handle calling mixin with empty args

This commit is contained in:
ConnorSkees 2020-01-26 13:52:47 -05:00
parent 620e33f541
commit 05eb03a38b

View File

@ -94,8 +94,8 @@ impl Mixin {
while let Some(expr) = eat_expr(&mut self.body, &self.scope, super_selector)? {
match expr {
Expr::Style(s) => stmts.push(Stmt::Style(s)),
Expr::Include(..)
| Expr::MixinDecl(..)
Expr::Include(s) => stmts.extend(s),
Expr::MixinDecl(..)
| Expr::FunctionDecl(..)
| Expr::Debug(..)
| Expr::Warn(..) => todo!(),
@ -137,7 +137,14 @@ pub(crate) fn eat_include<I: Iterator<Item = Token>>(
let args = if let Some(tok) = toks.next() {
match tok.kind {
TokenKind::Symbol(Symbol::SemiColon) => CallArgs::new(),
TokenKind::Symbol(Symbol::OpenParen) => eat_call_args(toks, scope),
TokenKind::Symbol(Symbol::OpenParen) => {
let tmp = eat_call_args(toks, scope);
devour_whitespace(toks);
if let Some(tok) = toks.next() {
assert_eq!(tok.kind, TokenKind::Symbol(Symbol::SemiColon));
}
tmp
},
_ => return Err((pos, String::from("expected `(` or `;`"))),
}
} else {
@ -146,14 +153,6 @@ pub(crate) fn eat_include<I: Iterator<Item = Token>>(
devour_whitespace(toks);
if !args.is_empty() {
if let Some(tok) = toks.next() {
assert_eq!(tok.kind, TokenKind::Symbol(Symbol::SemiColon));
}
}
devour_whitespace(toks);
let mixin = match scope.mixins.get(&name) {
Some(m) => m.clone(),
_ => return Err((pos, String::from("Expected identifier."))),