From 8dbd57a6a5fe497bde9e647a3249c1ce0ea121ab Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Fri, 11 Sep 2020 19:21:40 +0200 Subject: [PATCH] Fix auto argument passing for more auto arguments than formals The change in 626200713bb3cc844a9feb6af583c9b6b42c6dbc didn't account for when the number of auto arguments is bigger than the number of formal arguments. This causes the following: $ nix-instantiate --eval -E '{ ... }@args: args.foo' --argstr foo foo nix-instantiate: src/libexpr/attr-set.hh:55: void nix::Bindings::push_back(const nix::Attr&): Assertion `size_ < capacity_' failed. Aborted (core dumped) --- src/libexpr/eval.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index 8c97b3760..dab11ce45 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -1348,7 +1348,7 @@ void EvalState::autoCallFunction(Bindings & args, Value & fun, Value & res) } Value * actualArgs = allocValue(); - mkAttrs(*actualArgs, fun.lambda.fun->formals->formals.size()); + mkAttrs(*actualArgs, std::max(static_cast(fun.lambda.fun->formals->formals.size()), args.size())); if (fun.lambda.fun->formals->ellipsis) { // If the formals have an ellipsis (eg the function accepts extra args) pass