diff --git a/src/builtin/meta.rs b/src/builtin/meta.rs index d37cd47..bf7fc02 100644 --- a/src/builtin/meta.rs +++ b/src/builtin/meta.rs @@ -188,8 +188,8 @@ fn get_function(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult SassFunction::UserDefined(Box::new(f), name), - Err(..) => match GLOBAL_FUNCTIONS.get(name.as_str()) { + Some(f) => SassFunction::UserDefined(Box::new(f), name), + None => match GLOBAL_FUNCTIONS.get(name.as_str()) { Some(f) => SassFunction::Builtin(f.clone(), name), None => return Err((format!("Function not found: {}", name), args.span()).into()), }, diff --git a/src/parse/value/parse.rs b/src/parse/value/parse.rs index 51d4cdb..c890ddb 100644 --- a/src/parse/value/parse.rs +++ b/src/parse/value/parse.rs @@ -263,8 +263,8 @@ impl<'a> Parser<'a> { }, self.global_scope, ) { - Ok(f) => f, - Err(_) => { + Some(f) => f, + None => { if let Some(f) = GLOBAL_FUNCTIONS.get(as_ident.as_str()) { return Ok(IntermediateValue::Value(HigherIntermediateValue::Function( SassFunction::Builtin(f.clone(), as_ident), diff --git a/src/scope.rs b/src/scope.rs index c4f5aef..90e30f7 100644 --- a/src/scope.rs +++ b/src/scope.rs @@ -57,11 +57,8 @@ impl Scope { self.mixins.contains_key(name) } - fn get_fn(&self, name: Spanned<&Identifier>) -> SassResult { - match self.functions.get(name.node) { - Some(v) => Ok(v.clone()), - None => Err(("Undefined function.", name.span).into()), - } + fn get_fn(&self, name: &Identifier) -> Option { + self.functions.get(name).cloned() } pub fn insert_fn>(&mut self, s: T, v: Function) -> Option { @@ -218,13 +215,13 @@ impl Scopes { &'a self, name: Spanned<&Identifier>, global_scope: &'a Scope, - ) -> SassResult { + ) -> Option { for scope in self.0.iter().rev() { if scope.fn_exists(&name.node) { - return scope.get_fn(name); + return scope.get_fn(name.node); } } - global_scope.get_fn(name) + global_scope.get_fn(name.node) } pub fn fn_exists(&self, name: &Identifier, global_scope: &Scope) -> bool {