diff --git a/src/parse/variable.rs b/src/parse/variable.rs index 9e12aed..cd65284 100644 --- a/src/parse/variable.rs +++ b/src/parse/variable.rs @@ -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(()) } diff --git a/tests/variables.rs b/tests/variables.rs index 8a779b5..2d1f8c7 100644 --- a/tests/variables.rs +++ b/tests/variables.rs @@ -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,