From 334ce7375544018c11c51bfb8ab1428ae4f57f38 Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Mon, 11 Sep 2023 01:20:08 +0200 Subject: [PATCH] Don't support overrides --- src/transformers/attribute-sets.js | 6 ++++++ tests/upstream-nix.js | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/src/transformers/attribute-sets.js b/src/transformers/attribute-sets.js index 5733395..709d1cd 100644 --- a/src/transformers/attribute-sets.js +++ b/src/transformers/attribute-sets.js @@ -13,6 +13,7 @@ const objectLiteral = require("./templates/object-literal"); // TODO: Optimize lazy evaluation wrappers by only unpacking them selectively when used in an actual expression; in particular, that avoids the "wrapper that just calls another wrapper" overhead when passing attributes as function arguments // TODO: Change to a prototype-based scope object chain? This should produce more consistent output regardless of whether a given set of bindings is static vs. dynamic and recursive vs. non-recursive +// TODO: Implement __overrides support. Maybe. If I am ever truly desperate for a torturous task. nixpkgs yote it all the way back in 2014 because it is so broken. let tmplAssertKeys = template(` $assertUniqueKeys( %%keyList%% ) @@ -162,8 +163,13 @@ module.exports = { }); let hasDynamicBindings = bindings.some((binding) => typeof binding.name !== "string"); + let hasOverrides = bindings.some((binding) => binding.name === "__overrides"); if (isRecursive) { + if (hasOverrides) { + throw new Error(`The __overrides feature is not supported in jsNix`); + } + if (hasDynamicBindings) { return objectRecursiveDynamic(bindings); } else { diff --git a/tests/upstream-nix.js b/tests/upstream-nix.js index 09e8d71..f2ab7f7 100644 --- a/tests/upstream-nix.js +++ b/tests/upstream-nix.js @@ -1,5 +1,10 @@ "use strict"; +let ignoredTests = new Set([ + // We do not support the overrides feature at all, and probably never will + "eval-okay-overrides" +]); + try { const tape = require("tape-catch"); const fs = require("fs"); @@ -31,6 +36,10 @@ try { for (let test of tests) { try { + if (ignoredTests.has(test)) { + continue; + } + let expression = fs.readFileSync(path.join(testsPath, `${test}.nix`), "utf8"); let expectedResult = fs.readFileSync(path.join(testsPath, `${test}.exp`), "utf8").replace(/\n$/, "");