fix @each bug involving list containing map with multiple elements

This commit is contained in:
Connor Skees 2020-07-06 23:11:46 -04:00
parent 7971bfe98b
commit 49607da222
2 changed files with 21 additions and 20 deletions

View File

@ -10,7 +10,6 @@ use crate::{
media::MediaRule,
AtRuleKind, Content, SupportsRule, UnknownAtRule,
},
common::{Brackets, ListSeparator},
error::SassResult,
scope::Scope,
selector::{
@ -914,28 +913,17 @@ impl<'a> Parser<'a> {
let mut stmts = Vec::new();
for row in iter {
let this_iterator = row.clone().as_list();
if vars.len() == 1 {
if this_iterator.len() == 1 {
self.scopes.last_mut().insert_var(
&vars[0].node,
Spanned {
node: row,
span: vars[0].span,
},
);
} else {
self.scopes.last_mut().insert_var(
&vars[0].node,
Spanned {
node: Value::List(this_iterator, ListSeparator::Space, Brackets::None),
span: vars[0].span,
},
);
}
self.scopes.last_mut().insert_var(
&vars[0].node,
Spanned {
node: row,
span: vars[0].span,
},
);
} else {
for (var, val) in vars.iter().zip(
this_iterator
row.as_list()
.into_iter()
.chain(std::iter::once(Value::Null).cycle()),
) {

View File

@ -48,6 +48,19 @@ test!(
"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"
);
test!(
list_of_single_map_with_multiple_elements,
"a {
$settings: ();
@each $config in [(a: b, c: d)] {
$settings: map-merge($settings, $config);
}
color: inspect($settings);
}",
"a {\n color: (a: b, c: d);\n}\n"
);
error!(
list_of_single_map,
"a {