mirror of
https://github.com/NixOS/nix
synced 2025-07-13 17:10:47 +02:00
Merge pull request #13450 from xokdvium/formal-call-unreachable
libexpr: Fix invalid handling of errors for imported functions
This commit is contained in:
commit
b196922bcc
6 changed files with 33 additions and 2 deletions
|
@ -1602,7 +1602,7 @@ void EvalState::callFunction(Value & fun, std::span<Value *> args, Value & vRes,
|
|||
symbols[i.name])
|
||||
.atPos(lambda.pos)
|
||||
.withTrace(pos, "from call site")
|
||||
.withFrame(*fun.lambda().env, lambda)
|
||||
.withFrame(*vCur.lambda().env, lambda)
|
||||
.debugThrow();
|
||||
}
|
||||
env2.values[displ++] = i.def->maybeThunk(*this, env2);
|
||||
|
@ -1629,7 +1629,7 @@ void EvalState::callFunction(Value & fun, std::span<Value *> args, Value & vRes,
|
|||
.atPos(lambda.pos)
|
||||
.withTrace(pos, "from call site")
|
||||
.withSuggestions(suggestions)
|
||||
.withFrame(*fun.lambda().env, lambda)
|
||||
.withFrame(*vCur.lambda().env, lambda)
|
||||
.debugThrow();
|
||||
}
|
||||
unreachable();
|
||||
|
|
12
tests/functional/lang/eval-fail-missing-arg-import.err.exp
Normal file
12
tests/functional/lang/eval-fail-missing-arg-import.err.exp
Normal file
|
@ -0,0 +1,12 @@
|
|||
error:
|
||||
… from call site
|
||||
at /pwd/lang/eval-fail-missing-arg-import.nix:1:1:
|
||||
1| import ./non-eval-trivial-lambda-formals.nix { }
|
||||
| ^
|
||||
2|
|
||||
|
||||
error: function 'anonymous lambda' called without required argument 'a'
|
||||
at /pwd/lang/non-eval-trivial-lambda-formals.nix:1:1:
|
||||
1| { a }: a
|
||||
| ^
|
||||
2|
|
1
tests/functional/lang/eval-fail-missing-arg-import.nix
Normal file
1
tests/functional/lang/eval-fail-missing-arg-import.nix
Normal file
|
@ -0,0 +1 @@
|
|||
import ./non-eval-trivial-lambda-formals.nix { }
|
|
@ -0,0 +1,13 @@
|
|||
error:
|
||||
… from call site
|
||||
at /pwd/lang/eval-fail-undeclared-arg-import.nix:1:1:
|
||||
1| import ./non-eval-trivial-lambda-formals.nix {
|
||||
| ^
|
||||
2| a = "a";
|
||||
|
||||
error: function 'anonymous lambda' called with unexpected argument 'b'
|
||||
at /pwd/lang/non-eval-trivial-lambda-formals.nix:1:1:
|
||||
1| { a }: a
|
||||
| ^
|
||||
2|
|
||||
Did you mean a?
|
|
@ -0,0 +1,4 @@
|
|||
import ./non-eval-trivial-lambda-formals.nix {
|
||||
a = "a";
|
||||
b = "b";
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
{ a }: a
|
Loading…
Add table
Add a link
Reference in a new issue