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

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

View File

@ -259,6 +259,36 @@ test!(
}",
"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
test!(
regression_test_for_lasso_0_3_0,