about summary refs log tree commit diff
path: root/third_party/nix/src/libexpr
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/nix/src/libexpr')
-rw-r--r--third_party/nix/src/libexpr/eval.cc29
1 files changed, 20 insertions, 9 deletions
diff --git a/third_party/nix/src/libexpr/eval.cc b/third_party/nix/src/libexpr/eval.cc
index 569e04e3a712..b735495f2132 100644
--- a/third_party/nix/src/libexpr/eval.cc
+++ b/third_party/nix/src/libexpr/eval.cc
@@ -1117,15 +1117,26 @@ void EvalState::autoCallFunction(Bindings* args, Value& fun, Value& res) {
   Value* actualArgs = allocValue();
   mkAttrs(*actualArgs, fun.lambda.fun->formals->formals.size());
 
-  for (auto& i : fun.lambda.fun->formals->formals) {
-    Bindings::iterator j = args->find(i.name);
-    if (j != args->end()) {
-      actualArgs->attrs->push_back(j->second);
-    } else if (i.def == nullptr) {
-      throwTypeError(
-          "cannot auto-call a function that has an argument without a default "
-          "value ('%1%')",
-          i.name);
+  if (fun.lambda.fun->formals->ellipsis) {
+    // If the formals have an ellipsis (eg the function accepts extra args) pass
+    // all available automatic arguments (which includes arguments specified on
+    // the command line via --arg/--argstr)
+    for (auto& [_, v] : *args) {
+      actualArgs->attrs->push_back(v);
+    }
+  } else {
+    // Otherwise, only pass the arguments that the function accepts
+    for (auto& i : fun.lambda.fun->formals->formals) {
+      Bindings::iterator j = args->find(i.name);
+      if (j != args->end()) {
+        actualArgs->attrs->push_back(j->second);
+      } else if (i.def == nullptr) {
+        throwTypeError(
+            "cannot auto-call a function that has an argument without a "
+            "default "
+            "value ('%1%')",
+            i.name);
+      }
     }
   }