about summary refs log tree commit diff
path: root/tvix/eval/src/opcode.rs
diff options
context:
space:
mode:
authorsterni <sternenseemann@systemli.org>2023-12-13T13·52+0100
committerclbot <clbot@tvl.fyi>2023-12-14T13·15+0000
commit7165ebc43bfb1b53929fb31673c512bbbdbe4096 (patch)
tree99e818716faca25777ea15499ce670a506269bed /tvix/eval/src/opcode.rs
parenta30dd0905a08a78bb0573136064dd334a0567f6a (diff)
fix(tvix/eval): remove incorrect imports when coercing r/7218
The default behavior of string coercion in C++ Nix is to weakly coerce
and import to store if necessary. There is a flag to make it strongly
coerce (coerceMore) and a flag that controls whether path values have
the corresponding file/directory imported into the store before
returning the (store) path as a string (copyToStore). We need to
implement our equivalent to the copyToStore (import_paths) flag for the
benefit of weak coercions that don't import into the store (dirOf,
baseNameOf, readFile, ...) and strong coercions that don't import into
the store (toString).

This makes coerce_to_string as well as CoercionKind weirder and more
versatile, but prevents us from reimplementing parts of the coercion
logic constantly as can be seen in the case of baseNameOf.

Note that it is not possible to test this properly in //tvix/eval tests
due to the lack of an appropriate EvalIO implementation being available.
Tests should be added to //tvix/glue down the line.

Change-Id: I8fb8ab99c7fe08e311d2ba1c36960746bf22f566
Reviewed-on: https://cl.tvl.fyi/c/depot/+/10361
Autosubmit: sterni <sternenseemann@systemli.org>
Tested-by: BuildkiteCI
Reviewed-by: Adam Joseph <adam@westernsemico.com>
Diffstat (limited to 'tvix/eval/src/opcode.rs')
-rw-r--r--tvix/eval/src/opcode.rs3
1 files changed, 2 insertions, 1 deletions
diff --git a/tvix/eval/src/opcode.rs b/tvix/eval/src/opcode.rs
index 4677981775..b57a79a3ba 100644
--- a/tvix/eval/src/opcode.rs
+++ b/tvix/eval/src/opcode.rs
@@ -202,7 +202,8 @@ pub enum OpCode {
     OpInterpolate(Count),
 
     /// Force the Value on the stack and coerce it to a string, always using
-    /// `CoercionKind::Weak`.
+    /// `CoercionKind::Weak { import_paths: true }`. This is the behavior
+    /// necessary for path interpolation.
     OpCoerceToString,
 
     // Paths