diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2020-08-31 14:24:26 +0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2020-08-31 14:24:26 +0200 |
commit | 84f5cabbeaed6b700e05fb4b4bab46c0ab1b5aa4 (patch) | |
tree | 66b8d8dbe049bedb299674adaf9931464113f4df /src/libexpr | |
parent | c3efef9275ce6db3d65a2eb97aee507e79b626a6 (diff) | |
parent | 56707218f601418b211f37a7b44f671ab3dacd8d (diff) |
Merge remote-tracking branch 'origin/master' into markdown
Diffstat (limited to 'src/libexpr')
-rw-r--r-- | src/libexpr/eval.cc | 23 | ||||
-rw-r--r-- | src/libexpr/primops.cc | 2 |
2 files changed, 18 insertions, 7 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index 4f2fd36c1..8c97b3760 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -1350,12 +1350,23 @@ 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); - else if (!i.def) - 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); + } else if (!i.def) { + throwTypeError("cannot auto-call a function that has an argument without a default value ('%1%')", i.name); + } + } } actualArgs->attrs->sort(); diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc index 87eb7ae7b..3350d05d4 100644 --- a/src/libexpr/primops.cc +++ b/src/libexpr/primops.cc @@ -102,7 +102,7 @@ static void import(EvalState & state, const Pos & pos, Value & vPath, Value * vS if (auto optStorePath = isValidDerivationInStore()) { auto storePath = *optStorePath; - Derivation drv = readDerivation(*state.store, realPath, Derivation::nameFromPath(storePath)); + Derivation drv = state.store->readDerivation(storePath); Value & w = *state.allocValue(); state.mkAttrs(w, 3 + drv.outputs.size()); Value * v2 = state.allocAttr(w, state.sDrvPath); |