about summary refs log tree commit diff
path: root/src/libexpr
diff options
context:
space:
mode:
authorShea Levy <shea@shealevy.com>2015-11-25T16·57-0500
committerShea Levy <shea@shealevy.com>2015-11-25T16·57-0500
commitf3279701291a3229e9561d02bd53391a928137c6 (patch)
tree4dc020e059305a0b19229ba05b6574e60eeeb737 /src/libexpr
parentbfb6c4876aed5b77c237820da30d0519e480adf5 (diff)
parent9533532ce25563fa3a28bfb7acba09ac166490d7 (diff)
Merge branch 'auto-call-functor'
autoCallFunction now auto-calls functors
Diffstat (limited to 'src/libexpr')
-rw-r--r--src/libexpr/eval.cc11
1 files changed, 11 insertions, 0 deletions
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;