fix(tvix): Ensure prim_sort actually uses the right outlist

Previously the outlist would not be used, and it would sort god knows
what in the out value.

This was probably introduced by the std::vector refactoring, and the
language test for builtins.sort was disabled. Whatever reason there
was for disabling it seems to be gone, so we're re-enabling it.

Change-Id: I98941c2cad78df58ff7bea1ece3aaa4133e94bf8
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1757
Reviewed-by: kanepyork <rikingcoding@gmail.com>
Tested-by: BuildkiteCI
This commit is contained in:
Vincent Ambo 2020-08-15 02:51:59 +01:00 committed by tazjin
parent e458e5255a
commit 1a48f39078
2 changed files with 5 additions and 4 deletions

View file

@ -1600,9 +1600,10 @@ static void prim_sort(EvalState& state, const Pos& pos, Value** args,
state.forceList(*args[1], pos);
// Copy of the input list which can be sorted in place.
auto outlist = new NixList(*args[1]->list);
v.type = tList;
v.list = new NixList(*args[1]->list);
std::for_each(outlist->begin(), outlist->end(),
std::for_each(v.list->begin(), v.list->end(),
[&](Value* val) { state.forceValue(*val); });
auto comparator = [&](Value* a, Value* b) {
@ -1612,8 +1613,8 @@ static void prim_sort(EvalState& state, const Pos& pos, Value** args,
return CompareValues()(a, b);
}
Value vTmp1;
Value vTmp2;
Value vTmp1{};
Value vTmp2{};
state.callFunction(*args[0], *a, vTmp1, pos);
state.callFunction(vTmp1, *b, vTmp2, pos);
return state.forceBool(vTmp2, pos);