From 9533532ce25563fa3a28bfb7acba09ac166490d7 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Wed, 25 Nov 2015 11:56:14 -0500 Subject: autoCallFunction: Auto-call functors --- src/libexpr/eval.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src') diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index acf1fbdc1356..df1600bc1963 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; -- cgit 1.4.1