From ce833b7c0353badece48cd17bf3217690e55aa00 Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Sun, 26 Apr 2020 15:02:36 -0400 Subject: [PATCH] proper type for @each when single variable --- src/atrule/each_rule.rs | 24 +++++++++++++++++------- tests/each.rs | 5 +++++ 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/atrule/each_rule.rs b/src/atrule/each_rule.rs index e0a1fd4..99d2ec8 100644 --- a/src/atrule/each_rule.rs +++ b/src/atrule/each_rule.rs @@ -39,13 +39,23 @@ impl Each { }; if self.vars.len() == 1 { - scope.insert_var( - &self.vars[0], - Spanned { - node: Value::List(this_iterator, ListSeparator::Space, Brackets::None), - span: self.vars[0].span, - }, - )?; + if this_iterator.len() == 1 { + scope.insert_var( + &self.vars[0], + Spanned { + node: this_iterator[0].clone(), + span: self.vars[0].span, + }, + )?; + } else { + scope.insert_var( + &self.vars[0], + Spanned { + node: Value::List(this_iterator, ListSeparator::Space, Brackets::None), + span: self.vars[0].span, + }, + )?; + } } else { for (var, val) in self.vars.clone().into_iter().zip( this_iterator diff --git a/tests/each.rs b/tests/each.rs index 0a2faeb..59220f7 100644 --- a/tests/each.rs +++ b/tests/each.rs @@ -43,3 +43,8 @@ test!( "a {\n @each $i in (1 2 3) {\n color: $i;\n }\n}\n", "a {\n color: 1;\n color: 2;\n color: 3;\n}\n" ); +test!( + type_of_each_space_separated_single_var, + "a {\n @each $i in 1 2 3 {\n color: type-of($i);\n }\n}\n", + "a {\n color: number;\n color: number;\n color: number;\n}\n" +);