aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/eval.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/libexpr/eval.cc')
-rw-r--r--src/libexpr/eval.cc12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index 2b697882b..cf9f6c543 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -660,6 +660,14 @@ LocalNoInlineNoReturn(void throwUndefinedVarError(const Pos & pos, const char *
});
}
+LocalNoInlineNoReturn(void throwMissingArgumentError(const Pos & pos, const char * s, const string & s1))
+{
+ throw MissingArgumentError({
+ .hint = hintfmt(s, s1),
+ .errPos = pos
+ });
+}
+
LocalNoInline(void addErrorTrace(Error & e, const char * s, const string & s2))
{
e.addTrace(std::nullopt, s, s2);
@@ -1365,7 +1373,7 @@ void EvalState::autoCallFunction(Bindings & args, Value & fun, Value & res)
if (j != args.end()) {
actualArgs->attrs->push_back(*j);
} else if (!i.def) {
- throwUndefinedVarError(i.pos, R"(cannot auto-call a function that has an argument without a default value ('%1%')
+ throwMissingArgumentError(i.pos, R"(cannot auto-call a function that has an argument without a default value ('%1%')
An 'auto-call' is when a nix expression is evaluated without any external arguments.
If that nix expression is a function, and that function's arguments all have default
@@ -1373,7 +1381,7 @@ values, then all is well.
But if the function arguments don't have default values, evaluation fails.
-The classic case for this error is evaluating a nix file with nix-build that expects
+The classic case for this error is evaluating a nix file that expects
to be evaluated by callPackage.
# in 'callPackage' format: expression is a function that takes an argument 'stdenv'.
# callPackage would implicitly pull 'stdenv' from nixpkgs, then call this function.