@content may have call args even when it has no parens

This commit is contained in:
Connor Skees 2020-08-17 03:30:54 -04:00
parent 5bcf499942
commit a0786619de
2 changed files with 26 additions and 11 deletions

View File

@ -213,18 +213,20 @@ impl<'a> Parser<'a> {
let mut entered_scope = false;
if let Some(Token { kind: '(', .. }) = self.toks.peek() {
self.toks.next();
let args = self.parse_call_args()?;
if let Some(ref content_args) = content.content_args {
args.max_args(content_args.len())?;
let call_args = if self.consume_char_if_exists('(') {
self.parse_call_args()?
} else {
CallArgs::new(self.span_before)
};
let scope = self.eval_args(content_args.clone(), args)?;
scope_at_decl.enter_scope(scope);
entered_scope = true;
} else {
args.max_args(0)?;
}
if let Some(ref content_args) = content.content_args {
call_args.max_args(content_args.len())?;
let scope = self.eval_args(content_args.clone(), call_args)?;
scope_at_decl.enter_scope(scope);
entered_scope = true;
} else {
call_args.max_args(0)?;
}
let stmts = if let Some(body) = content.content.clone() {

View File

@ -525,6 +525,19 @@ test!(
}",
"a {\n color: red;\n}\n"
);
test!(
content_default_arg_value_no_parens,
"a {
@mixin foo {
@content;
}
@include foo using ($a: red) {
color: $a;
}
}",
"a {\n color: red;\n}\n"
);
error!(
mixin_in_function,
"@function foo() {