aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/eval-inline.hh
diff options
context:
space:
mode:
authoreldritch horrors <pennae@lix.systems>2024-03-04 06:36:36 +0100
committereldritch horrors <pennae@lix.systems>2024-03-04 07:11:25 +0100
commit2ba978800355189e263aa7fe13277fd62ce743bc (patch)
treec68b6e852052fe6be14a9c17e3884e3bd1779cf1 /src/libexpr/eval-inline.hh
parentd42cd24afe1ff417a33c769d666cb2af231ca40b (diff)
Merge pull request #9555 from 9999years/positions-in-errors
Pass positions when evaluating (cherry picked from commit c8458bd731eb1c74159bebe459ea00165e056b65) Change-Id: I1b4a5d58973be6264ffdb23b4492da200fdb71be
Diffstat (limited to 'src/libexpr/eval-inline.hh')
-rw-r--r--src/libexpr/eval-inline.hh12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/libexpr/eval-inline.hh b/src/libexpr/eval-inline.hh
index a988fa40c..c37b1d62b 100644
--- a/src/libexpr/eval-inline.hh
+++ b/src/libexpr/eval-inline.hh
@@ -103,8 +103,10 @@ void EvalState::forceValue(Value & v, Callable getPos)
throw;
}
}
- else if (v.isApp())
- callFunction(*v.app.left, *v.app.right, v, noPos);
+ else if (v.isApp()) {
+ PosIdx pos = getPos();
+ callFunction(*v.app.left, *v.app.right, v, pos);
+ }
else if (v.isBlackhole())
error("infinite recursion encountered").atPos(getPos()).template debugThrow<EvalError>();
}
@@ -121,9 +123,9 @@ template <typename Callable>
[[gnu::always_inline]]
inline void EvalState::forceAttrs(Value & v, Callable getPos, std::string_view errorCtx)
{
- forceValue(v, noPos);
+ PosIdx pos = getPos();
+ forceValue(v, pos);
if (v.type() != nAttrs) {
- PosIdx pos = getPos();
error("value is %1% while a set was expected", showType(v)).withTrace(pos, errorCtx).debugThrow<TypeError>();
}
}
@@ -132,7 +134,7 @@ inline void EvalState::forceAttrs(Value & v, Callable getPos, std::string_view e
[[gnu::always_inline]]
inline void EvalState::forceList(Value & v, const PosIdx pos, std::string_view errorCtx)
{
- forceValue(v, noPos);
+ forceValue(v, pos);
if (!v.isList()) {
error("value is %1% while a list was expected", showType(v)).withTrace(pos, errorCtx).debugThrow<TypeError>();
}