From 7811a3e056ea33ac81477ac6f39bb00e14311288 Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Fri, 14 Feb 2020 18:39:50 -0500 Subject: [PATCH] `function-exists` searches builtin functions and ignores quotes --- src/builtin/meta.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/builtin/meta.rs b/src/builtin/meta.rs index 76e6b79..edc0e02 100644 --- a/src/builtin/meta.rs +++ b/src/builtin/meta.rs @@ -1,6 +1,6 @@ use std::collections::BTreeMap; -use super::Builtin; +use super::{Builtin, GLOBAL_FUNCTIONS}; use crate::common::QuoteKind; use crate::units::Unit; use crate::value::Value; @@ -71,7 +71,8 @@ pub(crate) fn register(f: &mut BTreeMap) { }); decl!(f "function-exists", |args, scope| { let value = arg!(args, 0, "name"); - Some(Value::bool(scope.fn_exists(&value.to_string()))) + let s = value.eval().unquote().to_string(); + Some(Value::bool(scope.fn_exists(&s) || GLOBAL_FUNCTIONS.contains_key(&s))) }); decl!(f "call", |_args, _scope| { todo!("builtin function `call()` is blocked on refactoring how call args are stored and parsed")