From 6debd2ef5201733a7113c079fc9ee1935786f745 Mon Sep 17 00:00:00 2001 From: Connor Skees Date: Tue, 18 Aug 2020 05:55:54 -0400 Subject: [PATCH] `!global` variables declared inside control flow not at root do not also add variable to current scope --- src/parse/variable.rs | 8 ++------ tests/variables.rs | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/parse/variable.rs b/src/parse/variable.rs index cd65284..ae17055 100644 --- a/src/parse/variable.rs +++ b/src/parse/variable.rs @@ -105,12 +105,8 @@ impl<'a> Parser<'a> { } else { self.global_scope.insert_var(ident, value); } - } else { - if self.flags.in_control_flow() && global { - self.scopes.insert_var_last(ident, value); - } else { - self.scopes.insert_var(ident, value); - } + } else if !(self.flags.in_control_flow() && global) { + self.scopes.insert_var(ident, value); } Ok(()) } diff --git a/tests/variables.rs b/tests/variables.rs index 2d1f8c7..309fa44 100644 --- a/tests/variables.rs +++ b/tests/variables.rs @@ -289,6 +289,23 @@ test!( }", "a {\n color: c;\n}\n" ); +test!( + inside_style_inside_control_flow_declared_outer_global_comes_prior, + "$a: a; + + a { + $a: b; + + @if true { + $a: c !global; + color: $a; + $a: e; + } + + color: $a; + }", + "a {\n color: b;\n color: e;\n}\n" +); // https://github.com/Kixiron/lasso/issues/7 test!( regression_test_for_lasso_0_3_0,