aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Amado <kamadorueda@gmail.com>2022-01-21 10:43:16 -0500
committerKevin Amado <kamadorueda@gmail.com>2022-01-21 16:32:43 -0500
commitc3896e19d0001b4f729017aa96d0a44b6e479a52 (patch)
treef41be33aff11261bbb4f02ece3241cac102c4a34
parent1472e045a757af4e289801673b456b78ebf18933 (diff)
forceAttrs: make pos mandatory
-rw-r--r--src/libcmd/installables.cc2
-rw-r--r--src/libexpr/eval-cache.cc2
-rw-r--r--src/libexpr/eval.cc2
-rw-r--r--src/libexpr/get-drvs.cc2
-rw-r--r--src/libexpr/primops.cc4
-rw-r--r--src/nix/flake.cc5
-rw-r--r--src/nix/prefetch.cc4
-rw-r--r--src/nix/repl.cc4
8 files changed, 13 insertions, 12 deletions
diff --git a/src/libcmd/installables.cc b/src/libcmd/installables.cc
index 268861ce8..ec4f8f6f9 100644
--- a/src/libcmd/installables.cc
+++ b/src/libcmd/installables.cc
@@ -522,7 +522,7 @@ ref<eval_cache::EvalCache> openEvalCache(
auto vFlake = state.allocValue();
flake::callFlake(state, *lockedFlake, *vFlake);
- state.forceAttrs(*vFlake);
+ state.forceAttrs(*vFlake, noPos);
auto aOutputs = vFlake->attrs->get(state.symbols.create("outputs"));
assert(aOutputs);
diff --git a/src/libexpr/eval-cache.cc b/src/libexpr/eval-cache.cc
index a92acafa8..222a34116 100644
--- a/src/libexpr/eval-cache.cc
+++ b/src/libexpr/eval-cache.cc
@@ -336,7 +336,7 @@ Value & AttrCursor::getValue()
if (!_value) {
if (parent) {
auto & vParent = parent->first->getValue();
- root->state.forceAttrs(vParent);
+ root->state.forceAttrs(vParent, vParent.determinePos(noPos));
auto attr = vParent.attrs->get(parent->second);
if (!attr)
throw Error("attribute '%s' is unexpectedly missing", getAttrPathStr());
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index ee3d86296..e1c089b95 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -1132,7 +1132,7 @@ void ExprAttrs::eval(EvalState & state, Env & env, Value & v)
Hence we need __overrides.) */
if (hasOverrides) {
Value * vOverrides = (*v.attrs)[overrides->second.displ].value;
- state.forceAttrs(*vOverrides);
+ state.forceAttrs(*vOverrides, vOverrides->determinePos(noPos));
Bindings * newBnds = state.allocBindings(v.attrs->capacity() + vOverrides->attrs->size());
for (auto & i : *v.attrs)
newBnds->push_back(i);
diff --git a/src/libexpr/get-drvs.cc b/src/libexpr/get-drvs.cc
index fe1d11505..d7630fc3c 100644
--- a/src/libexpr/get-drvs.cc
+++ b/src/libexpr/get-drvs.cc
@@ -107,7 +107,7 @@ DrvInfo::Outputs DrvInfo::queryOutputs(bool onlyOutputsToInstall)
string name = state->forceStringNoCtx(*elem, *i->pos);
Bindings::iterator out = attrs->find(state->symbols.create(name));
if (out == attrs->end()) continue; // FIXME: throw error?
- state->forceAttrs(*out->value);
+ state->forceAttrs(*out->value, *i->pos);
/* And evaluate its ‘outPath’ attribute. */
Bindings::iterator outPath = out->value->attrs->find(state->sOutPath);
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc
index 074181e13..9ed1c85c6 100644
--- a/src/libexpr/primops.cc
+++ b/src/libexpr/primops.cc
@@ -214,7 +214,7 @@ static void import(EvalState & state, const Pos & pos, Value & vPath, Value * vS
if (!vScope)
state.evalFile(path, v);
else {
- state.forceAttrs(*vScope);
+ state.forceAttrs(*vScope, pos);
Env * env = &state.allocEnv(vScope->attrs->size());
env->up = &state.baseEnv;
@@ -2485,7 +2485,7 @@ static void prim_zipAttrsWith(EvalState & state, const Pos & pos, Value * * args
for (unsigned int n = 0; n < listSize; ++n) {
Value * vElem = listElems[n];
try {
- state.forceAttrs(*vElem);
+ state.forceAttrs(*vElem, noPos);
for (auto & attr : *vElem->attrs)
attrsSeen[attr.name].first++;
} catch (TypeError & e) {
diff --git a/src/nix/flake.cc b/src/nix/flake.cc
index 97f4d911c..486b43f0f 100644
--- a/src/nix/flake.cc
+++ b/src/nix/flake.cc
@@ -124,12 +124,13 @@ struct CmdFlakeLock : FlakeCommand
static void enumerateOutputs(EvalState & state, Value & vFlake,
std::function<void(const std::string & name, Value & vProvide, const Pos & pos)> callback)
{
- state.forceAttrs(vFlake);
+ auto pos = vFlake.determinePos(noPos);
+ state.forceAttrs(vFlake, pos);
auto aOutputs = vFlake.attrs->get(state.symbols.create("outputs"));
assert(aOutputs);
- state.forceAttrs(*aOutputs->value);
+ state.forceAttrs(*aOutputs->value, pos);
auto sHydraJobs = state.symbols.create("hydraJobs");
diff --git a/src/nix/prefetch.cc b/src/nix/prefetch.cc
index 768d37595..7044ead10 100644
--- a/src/nix/prefetch.cc
+++ b/src/nix/prefetch.cc
@@ -28,7 +28,7 @@ string resolveMirrorUrl(EvalState & state, string url)
Value vMirrors;
// FIXME: use nixpkgs flake
state.eval(state.parseExprFromString("import <nixpkgs/pkgs/build-support/fetchurl/mirrors.nix>", "."), vMirrors);
- state.forceAttrs(vMirrors);
+ state.forceAttrs(vMirrors, noPos);
auto mirrorList = vMirrors.attrs->find(state.symbols.create(mirrorName));
if (mirrorList == vMirrors.attrs->end())
@@ -196,7 +196,7 @@ static int main_nix_prefetch_url(int argc, char * * argv)
Value vRoot;
state->evalFile(path, vRoot);
Value & v(*findAlongAttrPath(*state, attrPath, autoArgs, vRoot).first);
- state->forceAttrs(v);
+ state->forceAttrs(v, noPos);
/* Extract the URL. */
auto & attr = v.attrs->need(state->symbols.create("urls"));
diff --git a/src/nix/repl.cc b/src/nix/repl.cc
index 5c2bf4bfd..8b6de1bf2 100644
--- a/src/nix/repl.cc
+++ b/src/nix/repl.cc
@@ -342,7 +342,7 @@ StringSet NixRepl::completePrefix(string prefix)
Expr * e = parseString(expr);
Value v;
e->eval(*state, *env, v);
- state->forceAttrs(v);
+ state->forceAttrs(v, noPos);
for (auto & i : *v.attrs) {
string name = i.name;
@@ -673,7 +673,7 @@ void NixRepl::reloadFiles()
void NixRepl::addAttrsToScope(Value & attrs)
{
- state->forceAttrs(attrs);
+ state->forceAttrs(attrs, attrs.determinePos(noPos));
if (displ + attrs.attrs->size() >= envSize)
throw Error("environment full; cannot add more variables");