about summary refs log tree commit diff
path: root/tvix/eval/src/value/mod.rs
diff options
context:
space:
mode:
authorsterni <sternenseemann@systemli.org>2022-09-13T18·11+0200
committerclbot <clbot@tvl.fyi>2022-09-15T20·58+0000
commit067f2b16f6f5d8fce73b8420a53b51a15c90f589 (patch)
treecdfa2d5a70b14d1b438769aa282273d8efc469ac /tvix/eval/src/value/mod.rs
parente834a2cbc47cf18d5f35bb258ccc754c54c4f4e1 (diff)
feat(tvix/eval): implement Value::coerce_to_path() r/4865
This function is necessary for all builtins that expect some form of
path as an argument. It is merely a wrapper around coerce_to_string that
can shortcut if we already have a path. The absolute path check is done
in the same way as in C++ Nix for compatibility, although it should
probably be revised in the long term (think about Windows, for example).

Since coercing to a path is not an operation possible in the language
directly, this function can live in the builtins module as the only
place it is required.

Change-Id: I69ed5455c00d193fea88b8fa83e28907a761cab5
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6574
Autosubmit: sterni <sternenseemann@systemli.org>
Reviewed-by: tazjin <tazjin@tvl.su>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/eval/src/value/mod.rs')
-rw-r--r--tvix/eval/src/value/mod.rs2
1 files changed, 2 insertions, 0 deletions
diff --git a/tvix/eval/src/value/mod.rs b/tvix/eval/src/value/mod.rs
index f8fb9c7b40b7..47096dd40912 100644
--- a/tvix/eval/src/value/mod.rs
+++ b/tvix/eval/src/value/mod.rs
@@ -101,6 +101,8 @@ impl Value {
         kind: CoercionKind,
         vm: &mut VM,
     ) -> Result<NixString, ErrorKind> {
+        // TODO: eventually, this will need to handle string context and importing
+        // files into the Nix store depending on what context the coercion happens in
         if let Value::Thunk(t) = self {
             t.force(vm)?;
         }