forked from lix-project/lix
missing argument error
This commit is contained in:
parent
7d9037035e
commit
3edfe6090e
2 changed files with 11 additions and 2 deletions
|
@ -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))
|
LocalNoInline(void addErrorTrace(Error & e, const char * s, const string & s2))
|
||||||
{
|
{
|
||||||
e.addTrace(std::nullopt, s, s2);
|
e.addTrace(std::nullopt, s, s2);
|
||||||
|
@ -1365,7 +1373,7 @@ void EvalState::autoCallFunction(Bindings & args, Value & fun, Value & res)
|
||||||
if (j != args.end()) {
|
if (j != args.end()) {
|
||||||
actualArgs->attrs->push_back(*j);
|
actualArgs->attrs->push_back(*j);
|
||||||
} else if (!i.def) {
|
} 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.
|
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
|
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.
|
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.
|
to be evaluated by callPackage.
|
||||||
# in 'callPackage' format: expression is a function that takes an argument 'stdenv'.
|
# in 'callPackage' format: expression is a function that takes an argument 'stdenv'.
|
||||||
# callPackage would implicitly pull 'stdenv' from nixpkgs, then call this function.
|
# callPackage would implicitly pull 'stdenv' from nixpkgs, then call this function.
|
||||||
|
|
|
@ -17,6 +17,7 @@ MakeError(ThrownError, AssertionError);
|
||||||
MakeError(Abort, EvalError);
|
MakeError(Abort, EvalError);
|
||||||
MakeError(TypeError, EvalError);
|
MakeError(TypeError, EvalError);
|
||||||
MakeError(UndefinedVarError, Error);
|
MakeError(UndefinedVarError, Error);
|
||||||
|
MakeError(MissingArgumentError, Error);
|
||||||
MakeError(RestrictedPathError, Error);
|
MakeError(RestrictedPathError, Error);
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue