fix(tvix/eval): Use natural arg order for call_with
Since we push arguments onto a stack when calling multi-argument functions, we actually were ending up calling `call_with` with the arguments in the *reverse order* - we patched around this by passing the arguments in the reverse order for `foldl'`, but it makes more sense to have them just be the order that the function would be called with in user surface code instead. Change-Id: Ifddb98f46970ac89872383709c3ce758dc965c65 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7067 Reviewed-by: sterni <sternenseemann@systemli.org> Autosubmit: grfn <grfn@gws.fyi> Tested-by: BuildkiteCI
This commit is contained in:
parent
d4569cb504
commit
89aee6443c
2 changed files with 3 additions and 2 deletions
|
@ -277,7 +277,7 @@ fn pure_builtins() -> Vec<Builtin> {
|
|||
let mut res = args.pop().unwrap();
|
||||
let op = args.pop().unwrap();
|
||||
for val in list {
|
||||
res = vm.call_with(&op, [val, res])?;
|
||||
res = vm.call_with(&op, [res, val])?;
|
||||
res.force(vm)?;
|
||||
}
|
||||
|
||||
|
|
|
@ -265,9 +265,10 @@ impl<'o> VM<'o> {
|
|||
pub fn call_with<I>(&mut self, callable: &Value, args: I) -> EvalResult<Value>
|
||||
where
|
||||
I: IntoIterator<Item = Value>,
|
||||
I::IntoIter: DoubleEndedIterator,
|
||||
{
|
||||
let mut num_args = 0_usize;
|
||||
for arg in args {
|
||||
for arg in args.into_iter().rev() {
|
||||
num_args += 1;
|
||||
self.push(arg);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue