properly recognize arglist of null as null

This commit is contained in:
Connor Skees 2020-07-08 23:49:30 -04:00
parent cee16fece7
commit 1b8e0ebcd2
4 changed files with 28 additions and 11 deletions

View File

@ -10,10 +10,10 @@ use crate::{
{Cow, Token}, {Cow, Token},
}; };
#[derive(Debug, Clone, Eq, PartialEq)] #[derive(Debug, Clone)]
pub(crate) struct FuncArgs(pub Vec<FuncArg>); pub(crate) struct FuncArgs(pub Vec<FuncArg>);
#[derive(Debug, Clone, Eq, PartialEq)] #[derive(Debug, Clone)]
pub(crate) struct FuncArg { pub(crate) struct FuncArg {
pub name: Identifier, pub name: Identifier,
pub default: Option<Vec<Token>>, pub default: Option<Vec<Token>>,
@ -89,7 +89,7 @@ impl CallArgs {
.iter() .iter()
.map(|a| { .map(|a| {
span = span.merge(a.span); span = span.merge(a.span);
Ok(a.node.to_css_string(a.span)?) a.node.to_css_string(a.span)
}) })
.collect::<SassResult<Vec<Cow<'static, str>>>>()? .collect::<SassResult<Vec<Cow<'static, str>>>>()?
.join(", "), .join(", "),

View File

@ -207,8 +207,7 @@ impl<'a> Parser<'a> {
let lower = s.to_ascii_lowercase(); let lower = s.to_ascii_lowercase();
if lower == "progid" && self.toks.peek().is_some() && self.toks.peek().unwrap().kind == ':' if lower == "progid" && matches!(self.toks.peek(), Some(Token { kind: ':', .. })) {
{
s = lower; s = lower;
self.toks.next(); self.toks.next();
s.push(':'); s.push(':');

View File

@ -112,12 +112,9 @@ impl Value {
Value::Null => true, Value::Null => true,
Value::String(i, QuoteKind::None) if i.is_empty() => true, Value::String(i, QuoteKind::None) if i.is_empty() => true,
Value::List(v, _, Brackets::Bracketed) if v.is_empty() => false, Value::List(v, _, Brackets::Bracketed) if v.is_empty() => false,
Value::List(v, ..) => v Value::List(v, ..) => v.iter().map(Value::is_null).all(|f| f),
.iter() Value::ArgList(v, ..) if v.is_empty() => false,
.map(Value::is_null) Value::ArgList(v, ..) => v.iter().map(|v| v.node.is_null()).all(|f| f),
.collect::<Vec<bool>>()
.into_iter()
.all(|f| f),
_ => false, _ => false,
} }
} }

View File

@ -73,3 +73,24 @@ test!(
}", }",
"a {\n color: (1,);\n}\n" "a {\n color: (1,);\n}\n"
); );
error!(
empty_arglist_is_error,
"@function foo($a...) {
@return $a;
}
a {
color: foo();
}",
"Error: () isn't a valid CSS value."
);
test!(
arglist_of_only_null_is_null,
"@function foo($a...) {
@return $a;
}
a {
color: foo(null, null);
}",
""
);