Merge pull request #2275 from volth/issue-1776

[bugfix] lib.concatMap and lib.mapAttrs to be builtins
This commit is contained in:
Eelco Dolstra 2018-07-05 17:42:06 +02:00 committed by GitHub
commit f1f4c257f4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1365,10 +1365,11 @@ static void prim_mapAttrs(EvalState & state, const Pos & pos, Value * * args, Va
state.mkAttrs(v, args[1]->attrs->size()); state.mkAttrs(v, args[1]->attrs->size());
for (auto & i : *args[1]->attrs) { for (auto & i : *args[1]->attrs) {
Value vName, vFun2; Value * vName = state.allocValue();
mkString(vName, i.name); Value * vFun2 = state.allocValue();
state.callFunction(*args[0], vName, vFun2, pos); mkString(*vName, i.name);
state.callFunction(vFun2, *i.value, *state.allocAttr(v, i.name), pos); state.callFunction(*args[0], *vName, *vFun2, pos);
mkApp(*state.allocAttr(v, i.name), *vFun2, *i.value);
} }
} }
@ -1658,7 +1659,6 @@ static void prim_concatMap(EvalState & state, const Pos & pos, Value * * args, V
for (unsigned int n = 0; n < nrLists; ++n) { for (unsigned int n = 0; n < nrLists; ++n) {
Value * vElem = args[1]->listElems()[n]; Value * vElem = args[1]->listElems()[n];
state.forceValue(*vElem);
state.callFunction(*args[0], *vElem, lists[n], pos); state.callFunction(*args[0], *vElem, lists[n], pos);
state.forceList(lists[n], pos); state.forceList(lists[n], pos);
len += lists[n].listSize(); len += lists[n].listSize();