mirror of
https://github.com/NixOS/nix
synced 2025-06-28 01:11:15 +02:00
libexpr: throw a more helpful eval-error if a builtin is not available due to a missing feature-flag
I found it somewhat confusing to have an error like error: attribute 'getFlake' missing if the required experimental-feature (`flakes`) is not enabled. Instead, I'd expect Nix to throw an error just like it's the case when using e.g. `nix flake` without `flakes` being enabled. With this change, the error looks like this: $ nix-instantiate -E 'builtins.getFlake "nixpkgs"' error: Cannot call 'builtins.getFlake' because experimental Nix feature 'flakes' is disabled. You can enable it via '--extra-experimental-features flakes'. at «string»:1:1: 1| builtins.getFlake "nixpkgs" | ^ I didn't use `settings.requireExperimentalFeature` here on purpose because this doesn't contain a position. Also, it doesn't seem as if we need to catch the error and check for the missing feature here since this already happens at evaluation time.
This commit is contained in:
parent
a0bb5c4130
commit
2b02ce0e48
5 changed files with 35 additions and 15 deletions
|
@ -15,7 +15,6 @@ struct RegisterPrimOp
|
|||
std::vector<std::string> args;
|
||||
size_t arity = 0;
|
||||
const char * doc;
|
||||
std::optional<std::string> requiredFeature;
|
||||
PrimOpFun fun;
|
||||
};
|
||||
|
||||
|
@ -28,8 +27,7 @@ struct RegisterPrimOp
|
|||
RegisterPrimOp(
|
||||
std::string name,
|
||||
size_t arity,
|
||||
PrimOpFun fun,
|
||||
std::optional<std::string> requiredFeature = {});
|
||||
PrimOpFun fun);
|
||||
|
||||
RegisterPrimOp(Info && info);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue