about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRyan Lahfa <tvl@lahfa.xyz>2023-12-25T21·06+0100
committerclbot <clbot@tvl.fyi>2023-12-29T21·58+0000
commit343ee0de57c4d44e6f4ac725eca7e7c4c34eab0d (patch)
tree792e04b9d935192ae5da880e0ee236bd96a6d96a
parent5dfb15d2c8d323979af33027a33f49244a6c892f (diff)
feat(tvix/eval): implement `hasContext` primop r/7281
`hasContext` is now functional.

Change-Id: I23b128afc9150b833bc0d9b042d31fee35badadb
Reviewed-on: https://cl.tvl.fyi/c/depot/+/10422
Tested-by: BuildkiteCI
Autosubmit: raitobezarius <tvl@lahfa.xyz>
Reviewed-by: tazjin <tazjin@tvl.su>
-rw-r--r--tvix/eval/docs/builtins.md2
-rw-r--r--tvix/eval/src/builtins/mod.rs7
2 files changed, 4 insertions, 5 deletions
diff --git a/tvix/eval/docs/builtins.md b/tvix/eval/docs/builtins.md
index 00af50484903..a232331896eb 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 341ee6096924..a79199339c13 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<Value, ErrorKind> {
-        Ok(Value::Catchable(CatchableErrorKind::UnimplementedFeature(
-            "hasContext".to_string(),
-        )))
+    async fn builtin_hasContext(co: GenCo, e: Value) -> Result<Value, ErrorKind> {
+        let v = e.to_str()?;
+        Ok(Value::Bool(v.has_context()))
     }
 
     #[builtin("hashString")]