diff options
author | Shea Levy <shea@shealevy.com> | 2015-11-25 11:56:14 -0500 |
---|---|---|
committer | Shea Levy <shea@shealevy.com> | 2015-11-25 11:56:14 -0500 |
commit | 9533532ce25563fa3a28bfb7acba09ac166490d7 (patch) | |
tree | e8d3479fb79a1b65f771e9e49991d64e798c06e0 /src | |
parent | 6c10bd7c5e946424996e3628e74ba433207aa90e (diff) |
autoCallFunction: Auto-call functors
Diffstat (limited to 'src')
-rw-r--r-- | src/libexpr/eval.cc | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index acf1fbdc1..df1600bc1 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -1032,6 +1032,17 @@ void EvalState::autoCallFunction(Bindings & args, Value & fun, Value & res) { forceValue(fun); + if (fun.type == tAttrs) { + auto found = fun.attrs->find(sFunctor); + if (found != fun.attrs->end()) { + forceValue(*found->value); + Value * v = allocValue(); + callFunction(*found->value, fun, *v, noPos); + forceValue(*v); + return autoCallFunction(args, *v, res); + } + } + if (fun.type != tLambda || !fun.lambda.fun->matchAttrs) { res = fun; return; |