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() {
Parser {
toks: &mut body.into_iter().peekmore(),
@ -212,8 +212,9 @@ impl<'a> Parser<'a> {
} else {
Vec::new()
};
self.content.push(content.clone());
self.scopes.exit_scope();
self.content.push(content);
stmts
} else {
Vec::new()

View File

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

View File

@ -449,6 +449,22 @@ test!(
}",
"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!(
mixin_in_function,
"@function foo() {