From e6bf1a79d70686ae48096f2c7227d8a363358ab4 Mon Sep 17 00:00:00 2001 From: volth Date: Thu, 5 Jul 2018 15:33:12 +0000 Subject: [PATCH 1/2] prim_mapAttrs: must be lazy to avoid infinite recursion --- src/libexpr/primops.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc index 9b4751970..ed4c0285b 100644 --- a/src/libexpr/primops.cc +++ b/src/libexpr/primops.cc @@ -1365,10 +1365,11 @@ static void prim_mapAttrs(EvalState & state, const Pos & pos, Value * * args, Va state.mkAttrs(v, args[1]->attrs->size()); for (auto & i : *args[1]->attrs) { - Value vName, vFun2; - mkString(vName, i.name); - state.callFunction(*args[0], vName, vFun2, pos); - state.callFunction(vFun2, *i.value, *state.allocAttr(v, i.name), pos); + Value * vName = state.allocValue(); + Value * vFun2 = state.allocValue(); + mkString(*vName, i.name); + state.callFunction(*args[0], *vName, *vFun2, pos); + mkApp(*state.allocAttr(v, i.name), *vFun2, *i.value); } } From 1515c6561688b216d27c732c8df43b65909fa03e Mon Sep 17 00:00:00 2001 From: volth Date: Thu, 5 Jul 2018 15:33:33 +0000 Subject: [PATCH 2/2] prim_concatMap: no need to force value --- src/libexpr/primops.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc index ed4c0285b..e71e3a6d4 100644 --- a/src/libexpr/primops.cc +++ b/src/libexpr/primops.cc @@ -1659,7 +1659,6 @@ static void prim_concatMap(EvalState & state, const Pos & pos, Value * * args, V for (unsigned int n = 0; n < nrLists; ++n) { Value * vElem = args[1]->listElems()[n]; - state.forceValue(*vElem); state.callFunction(*args[0], *vElem, lists[n], pos); state.forceList(lists[n], pos); len += lists[n].listSize();