From d9d94eb27f283fdfdbcc4af5eb5069201765d623 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Thu, 11 Aug 2022 13:12:07 +0300 Subject: feat(tvix/eval): implement if/else expressions 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 Reviewed-by: sterni --- tvix/eval/src/value/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tvix/eval/src/value/mod.rs') diff --git a/tvix/eval/src/value/mod.rs b/tvix/eval/src/value/mod.rs index 0c9042dbfe25..4a343797480e 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 { + pub fn as_bool(&self) -> EvalResult { match self { - Value::Bool(b) => Ok(b), + Value::Bool(b) => Ok(*b), other => Err(Error::TypeError { expected: "bool", actual: other.type_of(), -- cgit 1.4.1