From c68a55327b3034bf44477833160907738bf9f410 Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Sun, 16 Feb 2020 18:45:14 -0500 Subject: [PATCH] Unquote empty string is null --- src/builtin/string.rs | 2 +- tests/strings.rs | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/builtin/string.rs b/src/builtin/string.rs index 298a68a..fdf0eab 100644 --- a/src/builtin/string.rs +++ b/src/builtin/string.rs @@ -45,7 +45,7 @@ pub(crate) fn register(f: &mut BTreeMap) { decl!(f "unquote", |args, _| { max_args!(args, 1); match arg!(args, 0, "string").eval() { - Value::Ident(i, QuoteKind::None) if i.is_empty() => Ok(Value::Null), + Value::Ident(i, _) if i.is_empty() => Ok(Value::Null), i @ Value::Ident(..) => Ok(i.unquote()), v => Err(format!("$string: {} is not a string.", v).into()), } diff --git a/tests/strings.rs b/tests/strings.rs index 15f1a84..c1e9a16 100644 --- a/tests/strings.rs +++ b/tests/strings.rs @@ -93,6 +93,11 @@ test!( "a {\n color: str-length(cde);\n}\n", "a {\n color: 3;\n}\n" ); +test!( + unquote_empty_string_is_null, + "a {\n color: unquote('');\n}\n", + "" +); // blocked on refactoring how function-call args are parsed // right now, whitespace is eaten between idents with no // regard for quotes