fix(tvix/eval): force functors before applying them
call_value in the VM expects the callable to be forced when calling it, which was not the case for functors. Change-Id: Id55a2fe32a9573be42aef8669e268df519a989cd Reviewed-on: https://cl.tvl.fyi/c/depot/+/7909 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
This commit is contained in:
parent
b5d1ae4722
commit
d2f1a290a4
3 changed files with 12 additions and 0 deletions
|
@ -0,0 +1 @@
|
|||
42
|
|
@ -0,0 +1,7 @@
|
|||
let
|
||||
__functor = f;
|
||||
f = self: x: self.out * x;
|
||||
in {
|
||||
inherit __functor;
|
||||
out = 21;
|
||||
} 2
|
|
@ -406,6 +406,10 @@ impl<'o> VM<'o> {
|
|||
Value::Attrs(ref attrs) => match attrs.select("__functor") {
|
||||
None => Err(self.error(ErrorKind::NotCallable(callable.type_of()))),
|
||||
Some(functor) => {
|
||||
if let Value::Thunk(thunk) = &functor {
|
||||
fallible!(self, thunk.force(self));
|
||||
}
|
||||
|
||||
// The functor receives the set itself as its first argument
|
||||
// and needs to be called with it. However, this call is
|
||||
// synthetic (i.e. there is no corresponding OpCall for the
|
||||
|
|
Loading…
Reference in a new issue