1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-09 03:56:01 +01:00

Merge pull request #13451 from NixOS/mergify/bp/2.28-maintenance/pr-13450

libexpr: Fix invalid handling of errors for imported functions (backport #13450)
This commit is contained in:
Sergei Zimmerman 2025-07-11 23:34:01 +03:00 committed by GitHub
commit faaf5b86c6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 33 additions and 2 deletions

View file

@ -1564,7 +1564,7 @@ void EvalState::callFunction(Value & fun, std::span<Value *> args, Value & vRes,
symbols[i.name]) symbols[i.name])
.atPos(lambda.pos) .atPos(lambda.pos)
.withTrace(pos, "from call site") .withTrace(pos, "from call site")
.withFrame(*fun.payload.lambda.env, lambda) .withFrame(*vCur.payload.lambda.env, lambda)
.debugThrow(); .debugThrow();
} }
env2.values[displ++] = i.def->maybeThunk(*this, env2); env2.values[displ++] = i.def->maybeThunk(*this, env2);
@ -1591,7 +1591,7 @@ void EvalState::callFunction(Value & fun, std::span<Value *> args, Value & vRes,
.atPos(lambda.pos) .atPos(lambda.pos)
.withTrace(pos, "from call site") .withTrace(pos, "from call site")
.withSuggestions(suggestions) .withSuggestions(suggestions)
.withFrame(*fun.payload.lambda.env, lambda) .withFrame(*vCur.payload.lambda.env, lambda)
.debugThrow(); .debugThrow();
} }
unreachable(); unreachable();

View 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|

View file

@ -0,0 +1 @@
import ./non-eval-trivial-lambda-formals.nix { }

View file

@ -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?

View file

@ -0,0 +1,4 @@
import ./non-eval-trivial-lambda-formals.nix {
a = "a";
b = "b";
}

View file

@ -0,0 +1 @@
{ a }: a