We choose to throw an error in the invalid-input space where we *can* produce a valid (but wrong) result to allow ourselves to, mirroring CppNix, change the semantics to not corrupt it at all in the future, while having a middle state where it is an error. This is a largely-rewritten version of https://github.com/NixOS/nix/pull/13013. Co-authored-by: rootile <lix@rootile.de> Fixes: https://github.com/NixOS/nix/issues/12899 Upstream-PR: https://github.com/NixOS/nix/pull/13013 Change-Id: I6a6a6964cdd1a88714952e80c660d1fa57d1f2d8