aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/eval.cc
diff options
context:
space:
mode:
authorQyriad <qyriad@qyriad.me>2024-05-31 13:12:14 -0600
committerQyriad <qyriad@qyriad.me>2024-06-17 15:13:18 +0000
commit19a93dd02508a7a7dddde633f76044911acb5668 (patch)
tree7e709eee522aac06ead32805664fd5213a6ef1d6 /src/libexpr/eval.cc
parent010d93393e7dd978927f1c805c9b0c64e96b0ecc (diff)
mini-refactor "lambda.name or anonymous lambda" logic
Change-Id: I08d39c4ad5b967de526c0d5c5e6299256c7967f3
Diffstat (limited to 'src/libexpr/eval.cc')
-rw-r--r--src/libexpr/eval.cc12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index c72b69af2..22b5890bb 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -1595,7 +1595,7 @@ void EvalState::callFunction(Value & fun, size_t nrArgs, Value * * args, Value &
if (!j) {
if (!i.def) {
error<TypeError>("function '%1%' called without required argument '%2%'",
- (lambda.name ? std::string(symbols[lambda.name]) : "anonymous lambda"),
+ lambda.getName(symbols),
symbols[i.name])
.atPos(lambda.pos)
.withTrace(pos, "from call site")
@@ -1621,7 +1621,7 @@ void EvalState::callFunction(Value & fun, size_t nrArgs, Value * * args, Value &
formalNames.insert(symbols[formal.name]);
auto suggestions = Suggestions::bestMatches(formalNames, symbols[i.name]);
error<TypeError>("function '%1%' called with unexpected argument '%2%'",
- (lambda.name ? std::string(symbols[lambda.name]) : "anonymous lambda"),
+ lambda.getName(symbols),
symbols[i.name])
.atPos(lambda.pos)
.withTrace(pos, "from call site")
@@ -1642,9 +1642,7 @@ void EvalState::callFunction(Value & fun, size_t nrArgs, Value * * args, Value &
? makeDebugTraceStacker(
*this, *lambda.body, env2, positions[lambda.pos],
"while calling %s",
- lambda.name
- ? concatStrings("'", symbols[lambda.name], "'")
- : "anonymous lambda")
+ lambda.getQuotedName(symbols))
: nullptr;
lambda.body->eval(*this, env2, vCur);
@@ -1654,9 +1652,7 @@ void EvalState::callFunction(Value & fun, size_t nrArgs, Value * * args, Value &
e,
lambda.pos,
"while calling %s",
- lambda.name
- ? concatStrings("'", symbols[lambda.name], "'")
- : "anonymous lambda");
+ lambda.getQuotedName(symbols));
if (pos) addErrorTrace(e, pos, "from call site");
}
throw;