better handling of $module in get-function

This commit is contained in:
ConnorSkees 2020-04-04 12:45:30 -04:00
parent 065f6515e9
commit 943299de74
2 changed files with 7 additions and 3 deletions

View File

@ -143,9 +143,13 @@ pub(crate) fn register(f: &mut HashMap<String, Builtin>) {
v => return Err(format!("$name: {} is not a string.", v).into()),
};
let css = arg!(args, 1, "css" = Value::False).is_true()?;
let module = arg!(args, 2, "module" = Value::Null);
let module = match arg!(args, 2, "module" = Value::Null) {
Value::Ident(s, ..) => Some(s),
Value::Null => None,
v => return Err(format!("$module: {} is not a string.", v).into())
};
if !module.is_null() && css {
if module.is_some() && css {
return Err("$css and $module may not both be passed at once.".into());
}

View File

@ -55,7 +55,7 @@ impl Display for Value {
.collect::<Vec<String>>()
.join(", ")
),
Self::Function(..) => todo!("invalid CSS"),
Self::Function(func) => write!(f, "get-function(\"{}\")", func.name()),
Self::List(vals, sep, brackets) => match brackets {
Brackets::None => write!(
f,