correctly handle!global variables inside control flow when not at root

This commit is contained in:
Connor Skees 2020-08-18 03:55:26 -04:00
parent 48de92fdc0
commit 6630a1c2ea
2 changed files with 35 additions and 1 deletions

View File

@ -105,9 +105,13 @@ impl<'a> Parser<'a> {
} else { } else {
self.global_scope.insert_var(ident, value); self.global_scope.insert_var(ident, value);
} }
} else {
if self.flags.in_control_flow() && global {
self.scopes.insert_var_last(ident, value);
} else { } else {
self.scopes.insert_var(ident, value); self.scopes.insert_var(ident, value);
} }
}
Ok(()) Ok(())
} }

View File

@ -259,6 +259,36 @@ test!(
}", }",
"a {\n color: outer;\n}\n\na {\n color: outer;\n}\n" "a {\n color: outer;\n}\n\na {\n color: outer;\n}\n"
); );
test!(
global_inside_style_inside_control_flow_declared_outer,
"$y: a;
a {
$y: b;
@if true {
$y: c !global;
}
color: $y;
}",
"a {\n color: b;\n}\n"
);
test!(
inside_style_inside_control_flow_declared_outer,
"$y: a;
a {
$y: b;
@if true {
$y: c;
}
color: $y;
}",
"a {\n color: c;\n}\n"
);
// https://github.com/Kixiron/lasso/issues/7 // https://github.com/Kixiron/lasso/issues/7
test!( test!(
regression_test_for_lasso_0_3_0, regression_test_for_lasso_0_3_0,