From e6f2c26bc6b23bd1b62beed164abc68761a3f162 Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Mon, 23 Mar 2020 15:13:19 -0400 Subject: [PATCH] type-of(!important) returns 'string' --- src/value/mod.rs | 21 +++++++++++---------- tests/meta.rs | 5 +++++ 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/value/mod.rs b/src/value/mod.rs index cc8121b..9bb4e6f 100644 --- a/src/value/mod.rs +++ b/src/value/mod.rs @@ -24,6 +24,8 @@ pub(crate) enum Value { BinaryOp(Box, Op, Box), Paren(Box), Ident(String, QuoteKind), + // Returned by `get-function()` + // Function(String), } impl Display for Value { @@ -109,7 +111,7 @@ impl Value { pub fn is_true(&self) -> SassResult { match self { Value::Null | Value::False => Ok(false), - Self::BinaryOp(..) => self.clone().eval()?.is_true(), + Self::BinaryOp(..) | Self::Paren(..) | Self::UnaryOp(..) => self.clone().eval()?.is_true(), _ => Ok(true), } } @@ -123,15 +125,14 @@ impl Value { pub fn kind(&self) -> SassResult<&'static str> { match self { - Value::Color(..) => Ok("color"), - Value::Ident(..) => Ok("string"), - Value::Dimension(..) => Ok("number"), - Value::List(..) => Ok("list"), - // Value::Function(..) => Ok("function"), - Value::True | Value::False => Ok("bool"), - Value::Null => Ok("null"), - Value::BinaryOp(..) => self.clone().eval()?.kind(), - _ => Ok("unknown"), + Self::Color(..) => Ok("color"), + Self::Ident(..) | Self::Important => Ok("string"), + Self::Dimension(..) => Ok("number"), + Self::List(..) => Ok("list"), + // Self::Function(..) => Ok("function"), + Self::True | Self::False => Ok("bool"), + Self::Null => Ok("null"), + Self::BinaryOp(..) | Self::Paren(..) | Self::UnaryOp(..) => self.clone().eval()?.kind(), } } diff --git a/tests/meta.rs b/tests/meta.rs index bec8806..818200d 100644 --- a/tests/meta.rs +++ b/tests/meta.rs @@ -139,6 +139,11 @@ test!( "a {\n color: type-of(1 2 3)\n}\n", "a {\n color: list;\n}\n" ); +test!( + type_of_important, + "a {\n color: type-of(!important)\n}\n", + "a {\n color: string;\n}\n" +); test!( type_of_true, "a {\n color: type-of(true)\n}\n",