about summary refs log tree commit diff
path: root/tvix/eval/src
diff options
context:
space:
mode:
authorsterni <sternenseemann@systemli.org>2022-10-15T18·30+0200
committerclbot <clbot@tvl.fyi>2022-10-16T09·20+0000
commitdb70c672cf05f78df791ebcb20fa97c4cb786515 (patch)
tree4c4cff5c568836fdf3648c95ecd24cfd9b4b29fa /tvix/eval/src
parent96dcc5129788de960976f892b9f1a9ed216be363 (diff)
fix(tvix/eval): don't coerce variable name to string r/5141
Change-Id: I8aa878dee009901feb453c489ce37c12fa3a31a8
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7026
Autosubmit: sterni <sternenseemann@systemli.org>
Reviewed-by: Adam Joseph <adam@westernsemico.com>
Reviewed-by: tazjin <tazjin@tvl.su>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/eval/src')
-rw-r--r--tvix/eval/src/builtins/impure.rs6
-rw-r--r--tvix/eval/src/tests/tvix_tests/eval-fail-getEnv-coercion.nix1
2 files changed, 4 insertions, 3 deletions
diff --git a/tvix/eval/src/builtins/impure.rs b/tvix/eval/src/builtins/impure.rs
index 26422e263002..3d666528e271 100644
--- a/tvix/eval/src/builtins/impure.rs
+++ b/tvix/eval/src/builtins/impure.rs
@@ -11,15 +11,15 @@ use std::{
 use crate::{
     errors::ErrorKind,
     observer::NoOpObserver,
-    value::{Builtin, CoercionKind, NixAttrs, NixString, Thunk},
+    value::{Builtin, NixAttrs, NixString, Thunk},
     vm::VM,
     SourceCode, Value,
 };
 
 fn impure_builtins() -> Vec<Builtin> {
     vec![
-        Builtin::new("getEnv", &[true], |args: Vec<Value>, vm: &mut VM| {
-            Ok(env::var(args[0].coerce_to_string(CoercionKind::Weak, vm)?)
+        Builtin::new("getEnv", &[true], |args: Vec<Value>, _: &mut VM| {
+            Ok(env::var(args[0].to_str()?)
                 .unwrap_or_else(|_| "".into())
                 .into())
         }),
diff --git a/tvix/eval/src/tests/tvix_tests/eval-fail-getEnv-coercion.nix b/tvix/eval/src/tests/tvix_tests/eval-fail-getEnv-coercion.nix
new file mode 100644
index 000000000000..fe48a5690c46
--- /dev/null
+++ b/tvix/eval/src/tests/tvix_tests/eval-fail-getEnv-coercion.nix
@@ -0,0 +1 @@
+builtins.getEnv { var = "PATH"; __toString = self: self.var; }