From 60c16de830ae489642d17fa15d42f96a51acfe61 Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Fri, 3 Apr 2020 16:53:45 -0400 Subject: [PATCH] inspect([]) => [] --- src/builtin/meta.rs | 7 +++++-- tests/meta.rs | 5 +++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/builtin/meta.rs b/src/builtin/meta.rs index 8adc3a3..52bfda6 100644 --- a/src/builtin/meta.rs +++ b/src/builtin/meta.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use super::{Builtin, GLOBAL_FUNCTIONS}; -use crate::common::QuoteKind; +use crate::common::{Brackets, QuoteKind}; use crate::scope::global_var_exists; use crate::unit::Unit; use crate::value::Value; @@ -81,7 +81,10 @@ pub(crate) fn register(f: &mut HashMap) { max_args!(args, 1); Ok(Value::Ident( match arg!(args, 0, "value") { - Value::List(v, ..) if v.is_empty() => "()".to_string(), + Value::List(v, _, brackets) if v.is_empty() => match brackets { + Brackets::None => "()".to_string(), + Brackets::Bracketed => "[]".to_string(), + }, v => v.to_string(), }, QuoteKind::None, diff --git a/tests/meta.rs b/tests/meta.rs index 3519f0f..72353b5 100644 --- a/tests/meta.rs +++ b/tests/meta.rs @@ -239,6 +239,11 @@ test!( "a {\n color: inspect(null)\n}\n", "a {\n color: null;\n}\n" ); +test!( + inspect_empty_brackets, + "a {\n color: inspect([]);\n}\n", + "a {\n color: [];\n}\n" +); test!( variable_does_exist, "$a: red; a {\n color: variable-exists(a)\n}\n",