From 343ee0de57c4d44e6f4ac725eca7e7c4c34eab0d Mon Sep 17 00:00:00 2001 From: Ryan Lahfa Date: Mon, 25 Dec 2023 22:06:52 +0100 Subject: [PATCH] feat(tvix/eval): implement `hasContext` primop `hasContext` is now functional. Change-Id: I23b128afc9150b833bc0d9b042d31fee35badadb Reviewed-on: https://cl.tvl.fyi/c/depot/+/10422 Tested-by: BuildkiteCI Autosubmit: raitobezarius Reviewed-by: tazjin --- tvix/eval/docs/builtins.md | 2 +- tvix/eval/src/builtins/mod.rs | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/tvix/eval/docs/builtins.md b/tvix/eval/docs/builtins.md index 00af50484..a23233189 100644 --- a/tvix/eval/docs/builtins.md +++ b/tvix/eval/docs/builtins.md @@ -64,7 +64,7 @@ The `impl` column indicates implementation status in tvix: | getContext | false | | | context | | getEnv | false | | false | | | hasAttr | false | | | | -| hasContext | false | | | context | +| hasContext | false | | | | | hashFile | false | | false | todo | | hashString | false | | | todo | | head | false | | | | diff --git a/tvix/eval/src/builtins/mod.rs b/tvix/eval/src/builtins/mod.rs index 341ee6096..a79199339 100644 --- a/tvix/eval/src/builtins/mod.rs +++ b/tvix/eval/src/builtins/mod.rs @@ -551,10 +551,9 @@ mod pure_builtins { #[builtin("hasContext")] #[allow(non_snake_case)] - async fn builtin_hasContext(_co: GenCo, #[lazy] _e: Value) -> Result { - Ok(Value::Catchable(CatchableErrorKind::UnimplementedFeature( - "hasContext".to_string(), - ))) + async fn builtin_hasContext(co: GenCo, e: Value) -> Result { + let v = e.to_str()?; + Ok(Value::Bool(v.has_context())) } #[builtin("hashString")]