about summary refs log tree commit diff
path: root/tvix/eval/src/builtins/mod.rs
diff options
context:
space:
mode:
authorRyan Lahfa <tvl@lahfa.xyz>2023-12-25T21·07+0100
committerclbot <clbot@tvl.fyi>2024-01-03T23·24+0000
commit556e52c9cb8aa7b2af8bae75cd3365318e5d08c2 (patch)
treeab7c18bd41d27711039812fb182e4e89b0d66311 /tvix/eval/src/builtins/mod.rs
parent099ca6b7c0b95d1e7d5134ac465b50bbd86660c5 (diff)
feat(tvix/eval): impl `unsafeDiscardStringContext` r/7339
Change-Id: I7f0cc42cbebfe5cd27bf6d4f58a4af927b83646a
Reviewed-on: https://cl.tvl.fyi/c/depot/+/10423
Autosubmit: raitobezarius <tvl@lahfa.xyz>
Reviewed-by: tazjin <tazjin@tvl.su>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/eval/src/builtins/mod.rs')
-rw-r--r--tvix/eval/src/builtins/mod.rs23
1 files changed, 19 insertions, 4 deletions
diff --git a/tvix/eval/src/builtins/mod.rs b/tvix/eval/src/builtins/mod.rs
index 4cf9074fb8bf..b5adc3775fc0 100644
--- a/tvix/eval/src/builtins/mod.rs
+++ b/tvix/eval/src/builtins/mod.rs
@@ -1348,11 +1348,26 @@ mod placeholder_builtins {
 
     #[builtin("unsafeDiscardStringContext")]
     async fn builtin_unsafe_discard_string_context(
-        _: GenCo,
-        #[lazy] s: Value,
+        co: GenCo,
+        s: Value,
     ) -> Result<Value, ErrorKind> {
-        // Tvix does not manually track contexts, and this is a no-op for us.
-        Ok(s)
+        let span = generators::request_span(&co).await;
+        let mut v = s
+            .coerce_to_string(
+                co,
+                // It's weak because
+                // lists, integers, floats and null are not
+                // accepted as parameters.
+                CoercionKind {
+                    strong: false,
+                    import_paths: true,
+                },
+                span,
+            )
+            .await?
+            .to_contextful_str()?;
+        v.clear_context();
+        Ok(Value::String(v))
     }
 
     #[builtin("addErrorContext")]