variables declared in mixins can be accessed after @content

This commit is contained in:
Connor Skees 2020-07-30 22:26:24 -04:00
parent f587a36367
commit da9c0b78b2
3 changed files with 21 additions and 4 deletions

View File

@ -190,7 +190,7 @@ impl<'a> Parser<'a> {
} }
} }
Ok(if let Some(content) = &self.content.pop() { Ok(if let Some(content) = self.content.pop() {
let stmts = if let Some(body) = content.content.clone() { let stmts = if let Some(body) = content.content.clone() {
Parser { Parser {
toks: &mut body.into_iter().peekmore(), toks: &mut body.into_iter().peekmore(),
@ -212,8 +212,9 @@ impl<'a> Parser<'a> {
} else { } else {
Vec::new() Vec::new()
}; };
self.content.push(content.clone());
self.scopes.exit_scope(); self.content.push(content);
stmts stmts
} else { } else {
Vec::new() Vec::new()

View File

@ -105,7 +105,7 @@ impl Scopes {
if let Some(scope) = self.0.last_mut() { if let Some(scope) = self.0.last_mut() {
scope.merge(other) scope.merge(other)
} else { } else {
panic!() self.0.push(other)
} }
} }
} }

View File

@ -449,6 +449,22 @@ test!(
}", }",
"a {\n color: foo;\n color: foo;\n}\n" "a {\n color: foo;\n color: foo;\n}\n"
); );
test!(
can_access_variables_declared_before_content,
"@mixin foo {
$a: red;
@content;
color: $a;
}
a {
@include foo;
}",
"a {\n color: red;\n}\n"
);
error!( error!(
mixin_in_function, mixin_in_function,
"@function foo() { "@function foo() {