From a9be64012490417d1c341f830e8268137b3d03c4 Mon Sep 17 00:00:00 2001 From: Connor Skees Date: Sat, 15 Aug 2020 21:33:44 -0400 Subject: [PATCH] arguments do not affect variables in outer scopes --- src/parse/args.rs | 2 +- tests/args.rs | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/parse/args.rs b/src/parse/args.rs index f484bc3..561c98b 100644 --- a/src/parse/args.rs +++ b/src/parse/args.rs @@ -390,7 +390,7 @@ impl<'a> Parser<'a> { }, }? .node; - self.scopes.insert_var(arg.name, val.clone()); + self.scopes.insert_var_last(arg.name, val.clone()); scope.insert_var(arg.name, val); } self.scopes.exit_scope(); diff --git a/tests/args.rs b/tests/args.rs index 8cb7e81..f39457f 100644 --- a/tests/args.rs +++ b/tests/args.rs @@ -196,3 +196,20 @@ test!( }"#, "a {\n color: 'Roboto, \"Helvetica Neue\", sans-serif';\n}\n" ); +test!( + args_do_not_affect_existing_outer_variables, + "@mixin mixin2($a) { + color: $a; + } + + @mixin mixin1($a) { + color: $a; + @include mixin2(bar); + color: $a; + } + + a { + @include mixin1(foo); + }", + "a {\n color: foo;\n color: bar;\n color: foo;\n}\n" +);