diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index 0a6b199bf..29aa11035 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -1751,9 +1751,9 @@ void ExprCall::eval(EvalState & state, Env & env, Value & v) // 4: about 60 // 5: under 10 // This excluded attrset lambdas (`{...}:`). Contributions of mixed lambdas appears insignificant at ~150 total. - SmallValueVector<4> vArgs(args.size()); - for (size_t i = 0; i < args.size(); ++i) - vArgs[i] = args[i]->maybeThunk(state, env); + SmallValueVector<4> vArgs(args->size()); + for (size_t i = 0; i < args->size(); ++i) + vArgs[i] = (*args)[i]->maybeThunk(state, env); state.callFunction(vFun, vArgs, v, pos); } diff --git a/src/libexpr/include/nix/expr/nixexpr.hh b/src/libexpr/include/nix/expr/nixexpr.hh index 5121b9d98..e4880a3fb 100644 --- a/src/libexpr/include/nix/expr/nixexpr.hh +++ b/src/libexpr/include/nix/expr/nixexpr.hh @@ -592,7 +592,10 @@ public: struct ExprCall : Expr { Expr * fun; - std::pmr::vector args; + /** + * args will never be null. See comment on ExprAttrs::AttrDefs below. + */ + std::optional> args; PosIdx pos; std::optional cursedOrEndPos; // used during parsing to warn about https://github.com/NixOS/nix/issues/11118 diff --git a/src/libexpr/nixexpr.cc b/src/libexpr/nixexpr.cc index 3de5bdcb8..34d286f4e 100644 --- a/src/libexpr/nixexpr.cc +++ b/src/libexpr/nixexpr.cc @@ -191,7 +191,7 @@ void ExprCall::show(const SymbolTable & symbols, std::ostream & str) const { str << '('; fun->show(symbols, str); - for (auto e : args) { + for (auto e : *args) { str << ' '; e->show(symbols, str); } @@ -490,7 +490,7 @@ void ExprCall::bindVars(EvalState & es, const std::shared_ptr & es.exprEnvs.insert(std::make_pair(this, env)); fun->bindVars(es, env); - for (auto e : args) + for (auto e : *args) e->bindVars(es, env); } diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y index c4333eced..a9166c5b5 100644 --- a/src/libexpr/parser.y +++ b/src/libexpr/parser.y @@ -115,7 +115,7 @@ static void setDocPosition(const LexerState & lexerState, ExprLambda * lambda, P static Expr * makeCall(Exprs & exprs, PosIdx pos, Expr * fn, Expr * arg) { if (auto e2 = dynamic_cast(fn)) { - e2->args.push_back(arg); + e2->args->push_back(arg); return fn; } return exprs.add(pos, fn, {arg});