diff options
author | Vincent Ambo <tazjin@google.com> | 2020-05-22T00·58+0100 |
---|---|---|
committer | Vincent Ambo <tazjin@google.com> | 2020-05-22T00·59+0100 |
commit | 986a8f6b75ffa51682cbe730c5c2907296082cd4 (patch) | |
tree | 32c266920223bbfbf0beb49689dc05cb8eb1f2b7 /third_party/nix/src/libexpr/primops/context.cc | |
parent | 42205f27fc820ddc64616d55c04e2ffde1948043 (diff) |
fix(3p/nix): Update for usage of new attribute set API r/802
The new attribute set API uses the iterators of the btree_map directly. This requires changes in various files because the internals of libexpr are very entangled. This code runs and compiles, but there is a bug causing empty attribute sets to be assigned incorrectly.
Diffstat (limited to 'third_party/nix/src/libexpr/primops/context.cc')
-rw-r--r-- | third_party/nix/src/libexpr/primops/context.cc | 51 |
1 files changed, 26 insertions, 25 deletions
diff --git a/third_party/nix/src/libexpr/primops/context.cc b/third_party/nix/src/libexpr/primops/context.cc index efc94d91ced8..1661ffbe2e88 100644 --- a/third_party/nix/src/libexpr/primops/context.cc +++ b/third_party/nix/src/libexpr/primops/context.cc @@ -147,47 +147,48 @@ static void prim_appendContext(EvalState& state, const Pos& pos, Value** args, auto sPath = state.symbols.Create("path"); auto sAllOutputs = state.symbols.Create("allOutputs"); - for (auto& i : *args[1]->attrs) { - if (!state.store->isStorePath(i.name)) - throw EvalError("Context key '%s' is not a store path, at %s", i.name, - i.pos); + for (const auto& attr_iter : *args[1]->attrs) { + const Attr* i = &attr_iter.second; // TODO(tazjin): get rid of this + if (!state.store->isStorePath(i->name)) + throw EvalError("Context key '%s' is not a store path, at %s", i->name, + i->pos); if (!settings.readOnlyMode) { - state.store->ensurePath(i.name); + state.store->ensurePath(i->name); } - state.forceAttrs(*i.value, *i.pos); - auto iter = i.value->attrs->find(sPath); - if (iter != i.value->attrs->end()) { - if (state.forceBool(*iter->value, *iter->pos)) { - context.insert(i.name); + state.forceAttrs(*i->value, *i->pos); + auto iter = i->value->attrs->find(sPath); + if (iter != i->value->attrs->end()) { + if (state.forceBool(*iter->second.value, *iter->second.pos)) { + context.insert(i->name); } } - iter = i.value->attrs->find(sAllOutputs); - if (iter != i.value->attrs->end()) { - if (state.forceBool(*iter->value, *iter->pos)) { - if (!isDerivation(i.name)) { + iter = i->value->attrs->find(sAllOutputs); + if (iter != i->value->attrs->end()) { + if (state.forceBool(*iter->second.value, *iter->second.pos)) { + if (!isDerivation(i->name)) { throw EvalError( "Tried to add all-outputs context of %s, which is not a " "derivation, to a string, at %s", - i.name, i.pos); + i->name, i->pos); } - context.insert("=" + string(i.name)); + context.insert("=" + string(i->name)); } } - iter = i.value->attrs->find(state.sOutputs); - if (iter != i.value->attrs->end()) { - state.forceList(*iter->value, *iter->pos); - if (iter->value->listSize() && !isDerivation(i.name)) { + iter = i->value->attrs->find(state.sOutputs); + if (iter != i->value->attrs->end()) { + state.forceList(*iter->second.value, *iter->second.pos); + if (iter->second.value->listSize() && !isDerivation(i->name)) { throw EvalError( "Tried to add derivation output context of %s, which is not a " "derivation, to a string, at %s", - i.name, i.pos); + i->name, i->pos); } - for (unsigned int n = 0; n < iter->value->listSize(); ++n) { - auto name = - state.forceStringNoCtx(*iter->value->listElems()[n], *iter->pos); - context.insert("!" + name + "!" + string(i.name)); + for (unsigned int n = 0; n < iter->second.value->listSize(); ++n) { + auto name = state.forceStringNoCtx(*iter->second.value->listElems()[n], + *iter->second.pos); + context.insert("!" + name + "!" + string(i->name)); } } } |