feat(tvix/eval): add builtins.isNull

Change-Id: Iae251d41b4ac6b77df56078a954ec3e33b7f9ccf
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6256
Tested-by: BuildkiteCI
Reviewed-by: sterni <sternenseemann@systemli.org>
This commit is contained in:
Vincent Ambo 2022-08-24 16:24:01 +03:00 committed by tazjin
parent b8ac62d5fc
commit b41960c55e

View file

@ -17,6 +17,11 @@ macro_rules! builtin {
pub fn global_builtins() -> HashMap<&'static str, Value> {
let mut globals = HashMap::new();
builtin!(globals, "isNull", 1, |args| Ok(Value::Bool(matches!(
args[0],
Value::Null
))));
builtin!(globals, "toString", 1, |args| {
// TODO: toString is actually not the same as Display
Ok(Value::String(format!("{}", args[0]).into()))