diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2021-11-16 22:34:17 +0100 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2021-11-16 22:34:17 +0100 |
commit | d7bae52b9d418e208593c6641bce54f6a82458f4 (patch) | |
tree | fbe0ea4471eba3523a29c8eaec94fca721211b01 /src/libexpr/eval.cc | |
parent | e41cf8511f68e7e67786d8735d03c961c34cb2ad (diff) |
Call functors with both arguments at once
This is not really useful on its own, but it does recover the
'infinite recursion' error message for '{ __functor = x: x; } 1', and
is more efficient in conjunction with #3718.
Fixes #5515.
Diffstat (limited to 'src/libexpr/eval.cc')
-rw-r--r-- | src/libexpr/eval.cc | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index 615f020e4..f1ff3a6e0 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -1406,13 +1406,15 @@ void EvalState::callFunction(Value & fun, size_t nrArgs, Value * * args, Value & } else if (vCur.type() == nAttrs && (functor = vCur.attrs->get(sFunctor))) { - /* 'vCur" may be allocated on the stack of the calling + /* 'vCur' may be allocated on the stack of the calling function, but for functors we may keep a reference, so heap-allocate a copy and use that instead. */ - Value * args2[] = {allocValue()}; + Value * args2[] = {allocValue(), args[0]}; *args2[0] = vCur; /* !!! Should we use the attr pos here? */ - callFunction(*functor->value, 1, args2, vCur, pos); + callFunction(*functor->value, 2, args2, vCur, pos); + nrArgs--; + args++; } else |