From 076d1aa4cde33ecfed693e6b8da6f3e21088de32 Mon Sep 17 00:00:00 2001 From: piegames Date: Sun, 19 Apr 2026 16:38:05 +0200 Subject: [PATCH] eval: switch up ExprOpConcatLists error position again This is a minor adjustment to 2b22dae1ba1b0c4f5170e98a1279814e4cc4d907 / I3e9d7c1c7a6599a8e68302448bbb961d051002b7 Basically having the error point to the operand instead of the operator kind of makes sense, but it would require error spans to *truly* make sense, and in the meantime maintaining the logic is more hassle than it is worth. Change-Id: Idac98dd77a0f4a6cb386cb74e0d4eb5fd2f503e5 --- lix/libexpr/eval-expr.cc | 8 +++++--- tests/functional2/lang/list/eval-fail-2.err.exp | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lix/libexpr/eval-expr.cc b/lix/libexpr/eval-expr.cc index 6cd7a014d..0e1256a45 100644 --- a/lix/libexpr/eval-expr.cc +++ b/lix/libexpr/eval-expr.cc @@ -356,12 +356,14 @@ Value ExprOpConcatLists::eval(EvalState & state, Env & env) { state.ctx.stats.nrListConcats++; - /* We don't call into `concatLists` as that loses the position information of the expressions. */ + /* We could simply call into `state.concatLists`, but that would add a redundant trace to our errors, + * and to fix that we would need to make the error on it and `forceList` optional, and *sigh* + */ Value v1 = e1->eval(state, env); - state.checkList(v1, env, *e1); + state.checkList(v1, env, *this); // Pass in `this` instead of `e1` to make the error point to the `++` Value v2 = e2->eval(state, env); - state.checkList(v2, env, *e2); + state.checkList(v2, env, *this); // Pass in `this` instead of `e2` to make the error point to the `++` size_t l1 = v1.listSize(), l2 = v2.listSize(), len = l1 + l2; diff --git a/tests/functional2/lang/list/eval-fail-2.err.exp b/tests/functional2/lang/list/eval-fail-2.err.exp index 4de60e353..7177a71fa 100644 --- a/tests/functional2/lang/list/eval-fail-2.err.exp +++ b/tests/functional2/lang/list/eval-fail-2.err.exp @@ -1,5 +1,5 @@ error: expected a list but found an integer: 8 - at /pwd/in.nix:1:1: + at /pwd/in.nix:1:2: 1| 8++1 - | ^ + | ^ 2|