invert if stmt in parsing @content

This commit is contained in:
Connor Skees 2020-07-08 15:32:04 -04:00
parent 47902c077c
commit 316316d3a0

View File

@ -165,7 +165,14 @@ impl<'a> Parser<'a> {
} }
pub(super) fn parse_content_rule(&mut self) -> SassResult<Vec<Stmt>> { pub(super) fn parse_content_rule(&mut self) -> SassResult<Vec<Stmt>> {
if self.flags.in_mixin() { if !self.flags.in_mixin() {
return Err((
"@content is only allowed within mixin declarations.",
self.span_before,
)
.into());
}
let mut scope = self let mut scope = self
.content .content
.last() .last()
@ -175,9 +182,7 @@ impl<'a> Parser<'a> {
if let Some(Token { kind: '(', .. }) = self.toks.peek() { if let Some(Token { kind: '(', .. }) = self.toks.peek() {
self.toks.next(); self.toks.next();
let args = self.parse_call_args()?; let args = self.parse_call_args()?;
if let Some(Some(content_args)) = if let Some(Some(content_args)) = self.content.last().map(|v| v.content_args.clone()) {
self.content.last().map(|v| v.content_args.clone())
{
args.max_args(content_args.len())?; args.max_args(content_args.len())?;
scope.merge(self.eval_args(content_args, args)?); scope.merge(self.eval_args(content_args, args)?);
@ -212,12 +217,5 @@ impl<'a> Parser<'a> {
} else { } else {
Vec::new() Vec::new()
}) })
} else {
Err((
"@content is only allowed within mixin declarations.",
self.span_before,
)
.into())
}
} }
} }