!global variables are also in local scope
This commit is contained in:
parent
0979f3957b
commit
3afe88e2d6
@ -590,8 +590,9 @@ pub(crate) fn eat_expr<I: Iterator<Item = Token>>(
|
|||||||
global,
|
global,
|
||||||
} = eat_variable_value(toks, scope, super_selector)?;
|
} = eat_variable_value(toks, scope, super_selector)?;
|
||||||
if global {
|
if global {
|
||||||
insert_global_var(&name, val)?;
|
insert_global_var(&name, val.clone())?;
|
||||||
} else if !default || scope.get_var(&name).is_err() {
|
}
|
||||||
|
if !default || scope.get_var(&name).is_err() {
|
||||||
return Ok(Some(Expr::VariableDecl(name, Box::new(val))));
|
return Ok(Some(Expr::VariableDecl(name, Box::new(val))));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -13,3 +13,8 @@ test!(
|
|||||||
"a {\n $color: red !global;\n}\n\nb {\n color: $color;\n}\n",
|
"a {\n $color: red !global;\n}\n\nb {\n color: $color;\n}\n",
|
||||||
"b {\n color: red;\n}\n"
|
"b {\n color: red;\n}\n"
|
||||||
);
|
);
|
||||||
|
test!(
|
||||||
|
global_inserted_into_local_and_global_scopes,
|
||||||
|
"$foo: 42;\n\n.foo {\n content: $foo;\n $foo: 1337 !global;\n content: $foo;\n}\n\n.bar {\n content: $foo;\n}\n",
|
||||||
|
".foo {\n content: 42;\n content: 1337;\n}\n\n.bar {\n content: 1337;\n}\n"
|
||||||
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user