about summary refs log tree commit diff
path: root/tvix/eval/src/value/mod.rs
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-08-11T10·12+0300
committertazjin <tazjin@tvl.su>2022-08-25T16·00+0000
commitd9d94eb27f283fdfdbcc4af5eb5069201765d623 (patch)
tree7ab63ff7765904fdd4af5c56f637fe7066392a75 /tvix/eval/src/value/mod.rs
parent2422f2f2245e96fbed61200bb42d04b4e96a32b0 (diff)
feat(tvix/eval): implement if/else expressions r/4483
These expressions use simple jumps to skip the correct expression
conditionally in the bytecode by advancing the instruction pointer.

Note that these expressions are already covered by a test behind the
`nix_tests` feature flag, but adding more is probably sensible.

Change-Id: Ibe0eba95d216321c883d3b6b5816e2ab6fe7eef1
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6148
Tested-by: BuildkiteCI
Reviewed-by: grfn <grfn@gws.fyi>
Reviewed-by: sterni <sternenseemann@systemli.org>
Diffstat (limited to 'tvix/eval/src/value/mod.rs')
-rw-r--r--tvix/eval/src/value/mod.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/tvix/eval/src/value/mod.rs b/tvix/eval/src/value/mod.rs
index 0c9042dbfe..4a34379748 100644
--- a/tvix/eval/src/value/mod.rs
+++ b/tvix/eval/src/value/mod.rs
@@ -52,9 +52,9 @@ impl Value {
         }
     }
 
-    pub fn as_bool(self) -> EvalResult<bool> {
+    pub fn as_bool(&self) -> EvalResult<bool> {
         match self {
-            Value::Bool(b) => Ok(b),
+            Value::Bool(b) => Ok(*b),
             other => Err(Error::TypeError {
                 expected: "bool",
                 actual: other.type_of(),