diff --git a/src/value/mod.rs b/src/value/mod.rs index 0eed0a6..075e449 100644 --- a/src/value/mod.rs +++ b/src/value/mod.rs @@ -185,6 +185,9 @@ impl Value { Value::True => Cow::const_str("true"), Value::False => Cow::const_str("false"), Value::Null => Cow::const_str(""), + Value::ArgList(args) if args.is_empty() => { + return Err(("() isn't a valid CSS value.", span).into()); + } Value::ArgList(args) => Cow::owned( args.iter() .filter(|x| !x.is_null()) @@ -287,6 +290,7 @@ impl Value { .join(", ") )), Value::Dimension(num, unit) => Cow::owned(format!("{}{}", num, unit)), + Value::ArgList(args) if args.is_empty() => Cow::const_str("()"), Value::ArgList(args) => Cow::owned( args.iter() .filter(|x| !x.is_null()) diff --git a/tests/arglist.rs b/tests/arglist.rs index 4636417..e37ce97 100644 --- a/tests/arglist.rs +++ b/tests/arglist.rs @@ -21,7 +21,6 @@ test!( @each $number in $numbers { $sum: $sum + $number; } - @return $sum; } @@ -30,3 +29,25 @@ test!( }", "a {\n width: 180px;\n}\n" ); +error!( + emit_empty_arglist, + "@function foo($a...) { + @return $a; + } + + a { + color: foo(); + }", + "Error: () isn't a valid CSS value." +); +test!( + inspect_empty_arglist, + "@function foo($a...) { + @return inspect($a); + } + + a { + color: foo(); + }", + "a {\n color: ();\n}\n" +);