unsafeGetAttrPos
builtins.unsafeGetAttrPos
Primop
Docs pulled from | This Revision | about 19 hours ago
Nix manual
Takes 2 arguments
s, set
unsafeGetAttrPos returns the position of the attribute named s
from set. This is used by Nixpkgs to provide location information
in error messages.
Noogle detected
Implementation
This function is implemented in c++ and is part of the native nix runtime.
static void prim_unsafeGetAttrPos(EvalState & state, const PosIdx pos, Value ** args, Value & v)
{
auto attr = state.forceStringNoCtx(
*args[0], pos, "while evaluating the first argument passed to builtins.unsafeGetAttrPos");
state.forceAttrs(*args[1], pos, "while evaluating the second argument passed to builtins.unsafeGetAttrPos");
auto i = args[1]->attrs()->get(state.symbols.create(attr));
if (!i)
v.mkNull();
else
state.mkPos(v, i->pos);
}