libexpr: add set-to-string error frame
this is much more useful than a frame pointing to the set but claiming it as a function being called. if the function is actually at fault we will now point to its attribute, although the position may be slightly wrong if __toString was defined from set updates or builtin functions. Change-Id: Ib3eb237a276d94426d9c6fc0e26eea72382d34a2
This commit is contained in:
+9
-4
@@ -2309,10 +2309,15 @@ std::optional<std::string> EvalState::tryAttrsToString(const PosIdx pos, Value &
|
||||
auto i = v.attrs->find(ctx.s.toString);
|
||||
if (i != v.attrs->end()) {
|
||||
Value v1;
|
||||
callFunction(*i->value, v, v1, pos);
|
||||
return coerceToString(pos, v1, context,
|
||||
"while evaluating the result of the `__toString` attribute",
|
||||
coerceMore, copyToStore).toOwned();
|
||||
try {
|
||||
callFunction(*i->value, v, v1, i->pos);
|
||||
return coerceToString(pos, v1, context,
|
||||
"while evaluating the result of the `__toString` attribute",
|
||||
coerceMore, copyToStore).toOwned();
|
||||
} catch (EvalError & e) {
|
||||
e.addTrace(ctx.positions[pos], "while converting a set to string");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
return {};
|
||||
|
||||
Reference in New Issue
Block a user