eval varargs

This commit is contained in:
ConnorSkees 2020-06-22 10:21:18 -04:00
parent 082d58853b
commit ea0e04bfb9
2 changed files with 7 additions and 1 deletions

View File

@ -281,6 +281,7 @@ impl<'a> Parser<'a> {
pub fn variadic_args(&mut self, args: CallArgs) -> SassResult<Vec<Spanned<Value>>> {
let mut vals = Vec::new();
let span = args.span();
let mut args = match args
.0
.into_iter()
@ -292,7 +293,7 @@ impl<'a> Parser<'a> {
};
args.sort_by(|(a1, _), (a2, _)| a1.cmp(a2));
for arg in args {
vals.push(self.parse_value_from_vec(arg.1)?);
vals.push(self.parse_value_from_vec(arg.1)?.node.eval(span)?);
}
Ok(vals)
}

View File

@ -87,6 +87,11 @@ test!(
"$a: 1px;\n$b: 2px;\na {\n color: max($a, $b);\n}\n",
"a {\n color: 2px;\n}\n"
);
test!(
max_evaluated_binop,
"a {\n color: max(100% - lightness(red) - 2%);\n}\n",
"a {\n color: 52%;\n}\n"
);
error!(
max_arg_of_incorrect_type,
"$a: 1px;\n$b: 2px;\na {\n color: max($a, $b, foo);\n}\n", "Error: foo is not a number."