about summary refs log tree commit diff
path: root/src/libexpr/eval.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2006-07-26T15·05+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2006-07-26T15·05+0000
commitca2238cf818e27ebb663c83a9fe9ae7f58eb830f (patch)
tree7d8b058e7139c69666ee045f30070fc2500fafe5 /src/libexpr/eval.cc
parent2317d8f6712b2d4e249b8b1206f9e0a9c4269fc0 (diff)
* Refactoring: get the selection path stuff out of getDerivations()
  and put it into a separate function findAlongAttrPath().

Diffstat (limited to 'src/libexpr/eval.cc')
-rw-r--r--src/libexpr/eval.cc22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index f1a600103d..6c78356db8 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -287,6 +287,24 @@ static ATerm concatStrings(EvalState & state, const ATermVector & args)
 }
 
 
+Expr autoCallFunction(Expr e)
+{
+    ATermList formals;
+    ATerm body, pos;
+    if (matchFunction(e, formals, body, pos)) {
+        for (ATermIterator i(formals); i; ++i) {
+            Expr name, def; ATerm values, def2;
+            if (!matchFormal(*i, name, values, def2)) abort();
+            if (!matchDefaultValue(def2, def))
+                throw TypeError(format("cannot auto-call a function that has an argument without a default value (`%1%')")
+                    % aterm2String(name));
+        }
+        e = makeCall(e, makeAttrs(ATermMap(0)));
+    }
+    return e;
+}
+
+
 Expr evalExpr2(EvalState & state, Expr e)
 {
     Expr e1, e2, e3, e4;
@@ -380,7 +398,9 @@ Expr evalExpr2(EvalState & state, Expr e)
             }
         }
         
-        else throw TypeError("the left-hand side of the function call is neither a function nor a primop (built-in operation)");
+        else throw TypeError(
+            format("the left-hand side of the function call is neither a function nor a primop (built-in operation) but %1%")
+            % showType(e1));
     }
 
     /* Attribute selection. */