From c01bd37a8db48b01fffcb09ee7123a5312e1786c Mon Sep 17 00:00:00 2001 From: skye Date: Fri, 3 Apr 2026 13:56:05 -0400 Subject: [PATCH] libexpr/primops: Migrate helper fn elemAt to return a Value Part of #1136 Change-Id: Ib3c7040c7df729737643d3a9b833773d6a6a6964 --- lix/libexpr/primops.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lix/libexpr/primops.cc b/lix/libexpr/primops.cc index 2b3b8e302..e1a76700a 100644 --- a/lix/libexpr/primops.cc +++ b/lix/libexpr/primops.cc @@ -2244,27 +2244,27 @@ static void prim_isList(EvalState & state, Value * * args, Value & v) v = {NewValueAs::boolean, args[0]->type() == nList}; } -static void elemAt(EvalState & state, Value & list, NixInt::Inner n, Value & v) +static Value elemAt(EvalState & state, Value & list, NixInt::Inner n) { state.forceList(list, noPos, "while evaluating the first argument passed to builtins.elemAt"); if (n < 0 || std::make_unsigned_t(n) >= list.listSize()) { state.ctx.errors.make("list index %1% is out of bounds", n).debugThrow(); } state.forceValue(list.listElems()[n], noPos); - v = list.listElems()[n]; + return list.listElems()[n]; } /* Return the n-1'th element of a list. */ static void prim_elemAt(EvalState & state, Value * * args, Value & v) { NixInt::Inner elem = state.forceInt(*args[1], noPos, "while evaluating the second argument passed to builtins.elemAt").value; - elemAt(state, *args[0], elem, v); + v = elemAt(state, *args[0], elem); } /* Return the first element of a list. */ static void prim_head(EvalState & state, Value * * args, Value & v) { - elemAt(state, *args[0], 0, v); + v = elemAt(state, *args[0], 0); } /* Return a list consisting of everything but the first element of