From 8d95e35ced1de53af0030793b12714ce13c745a6 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Sun, 2 Oct 2022 18:39:48 +0300 Subject: fix(tvix/eval): do not fail when finalising non-capturing values This can actually legitimately be emitted by the compiler currently when compiling formals with default values. See the scope6 test from the Nix test suite for an example. We should restructure this slightly to be able to reintroduce a runtime error here in case something was compiled incorrectly. Change-Id: Ib81f0f58ae0e850db9fbc459458b7bd0d3ac6f23 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6841 Autosubmit: tazjin Reviewed-by: sterni Tested-by: BuildkiteCI --- tvix/eval/src/vm.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'tvix/eval/src') diff --git a/tvix/eval/src/vm.rs b/tvix/eval/src/vm.rs index 72d672688217..39c9c6e822df 100644 --- a/tvix/eval/src/vm.rs +++ b/tvix/eval/src/vm.rs @@ -589,7 +589,12 @@ impl<'o> VM<'o> { Value::Thunk(thunk) => thunk .resolve_deferred_upvalues(&self.stack[self.frame().stack_offset..]), - v => panic!("compiler error: invalid finaliser value: {}", v), + // In functions with "formals" attributes, it is + // possible for `OpFinalise` to be called on a + // non-capturing value, in which case it is a no-op. + // + // TODO: detect this in some phase and skip the finalise; fail here + _ => { /* TODO: panic here again to catch bugs */ } } } -- cgit 1.4.1