Merge pull request #2302 from volth/patch-3
prim_foldlStrict: call forceValue() before value is copied
This commit is contained in:
commit
925053e974
|
@ -1508,19 +1508,20 @@ static void prim_foldlStrict(EvalState & state, const Pos & pos, Value * * args,
|
||||||
state.forceFunction(*args[0], pos);
|
state.forceFunction(*args[0], pos);
|
||||||
state.forceList(*args[2], pos);
|
state.forceList(*args[2], pos);
|
||||||
|
|
||||||
Value * vCur = args[1];
|
if (args[2]->listSize()) {
|
||||||
|
Value * vCur = args[1];
|
||||||
|
|
||||||
if (args[2]->listSize())
|
|
||||||
for (unsigned int n = 0; n < args[2]->listSize(); ++n) {
|
for (unsigned int n = 0; n < args[2]->listSize(); ++n) {
|
||||||
Value vTmp;
|
Value vTmp;
|
||||||
state.callFunction(*args[0], *vCur, vTmp, pos);
|
state.callFunction(*args[0], *vCur, vTmp, pos);
|
||||||
vCur = n == args[2]->listSize() - 1 ? &v : state.allocValue();
|
vCur = n == args[2]->listSize() - 1 ? &v : state.allocValue();
|
||||||
state.callFunction(vTmp, *args[2]->listElems()[n], *vCur, pos);
|
state.callFunction(vTmp, *args[2]->listElems()[n], *vCur, pos);
|
||||||
}
|
}
|
||||||
else
|
state.forceValue(v);
|
||||||
v = *vCur;
|
} else {
|
||||||
|
state.forceValue(*args[1]);
|
||||||
state.forceValue(v);
|
v = *args[1];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue