about summary refs log tree commit diff
path: root/third_party/nix
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2020-08-15T01·51+0100
committertazjin <mail@tazj.in>2020-08-15T01·58+0000
commit1a48f390784a30df3e7e8259e71866d6916c5231 (patch)
treeb577f8c2f15b8dad005f589d3d442d8b4d36c119 /third_party/nix
parente458e5255ad9aff8b4831a288c4f694f329fc7f3 (diff)
fix(tvix): Ensure prim_sort actually uses the right outlist r/1655
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
Diffstat (limited to 'third_party/nix')
-rw-r--r--third_party/nix/src/libexpr/primops.cc9
-rw-r--r--third_party/nix/src/tests/lang/eval-okay-sort.nix (renamed from third_party/nix/src/tests/lang/disabled/eval-okay-sort.nix)0
2 files changed, 5 insertions, 4 deletions
diff --git a/third_party/nix/src/libexpr/primops.cc b/third_party/nix/src/libexpr/primops.cc
index 34d659675bf5..7819dd4b1380 100644
--- a/third_party/nix/src/libexpr/primops.cc
+++ b/third_party/nix/src/libexpr/primops.cc
@@ -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);
diff --git a/third_party/nix/src/tests/lang/disabled/eval-okay-sort.nix b/third_party/nix/src/tests/lang/eval-okay-sort.nix
index 8299c3a4a3aa..8299c3a4a3aa 100644
--- a/third_party/nix/src/tests/lang/disabled/eval-okay-sort.nix
+++ b/third_party/nix/src/tests/lang/eval-okay-sort.nix