diff options
author | Kevin Amado <kamadorueda@gmail.com> | 2021-11-27 12:40:24 -0500 |
---|---|---|
committer | Kevin Amado <kamadorueda@gmail.com> | 2022-01-21 16:32:43 -0500 |
commit | 49b0bb020663b7283549754a826b1346c93a8bbb (patch) | |
tree | 6415237a41abb754bcc51d426f3a85cd4f5f28aa /src/libcmd/installables.cc | |
parent | 5f08db69d18ea5b868cbb58993822e7dd0307518 (diff) |
forceValue: make pos mandatory
- Make passing the position to `forceValue` mandatory,
this way we remember people that the position is
important for better error messages
- Add pos to all `forceValue` calls
Diffstat (limited to 'src/libcmd/installables.cc')
-rw-r--r-- | src/libcmd/installables.cc | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/libcmd/installables.cc b/src/libcmd/installables.cc index 0c2db0399..268861ce8 100644 --- a/src/libcmd/installables.cc +++ b/src/libcmd/installables.cc @@ -198,8 +198,9 @@ void SourceExprCommand::completeInstallable(std::string_view prefix) prefix_ = ""; } - Value &v1(*findAlongAttrPath(*state, prefix_, *autoArgs, root).first); - state->forceValue(v1); + auto [v, pos] = findAlongAttrPath(*state, prefix_, *autoArgs, root); + Value &v1(*v); + state->forceValue(v1, pos); Value v2; state->autoCallFunction(*autoArgs, v1, v2); @@ -446,7 +447,7 @@ struct InstallableAttrPath : InstallableValue std::pair<Value *, Pos> toValue(EvalState & state) override { auto [vRes, pos] = findAlongAttrPath(state, attrPath, *cmd.getAutoArgs(state), **v); - state.forceValue(*vRes); + state.forceValue(*vRes, pos); return {vRes, pos}; } @@ -496,7 +497,7 @@ Value * InstallableFlake::getFlakeOutputs(EvalState & state, const flake::Locked auto aOutputs = vFlake->attrs->get(state.symbols.create("outputs")); assert(aOutputs); - state.forceValue(*aOutputs->value); + state.forceValue(*aOutputs->value, aOutputs->value->determinePos(noPos)); return aOutputs->value; } @@ -608,7 +609,7 @@ std::pair<Value *, Pos> InstallableFlake::toValue(EvalState & state) for (auto & attrPath : getActualAttrPaths()) { try { auto [v, pos] = findAlongAttrPath(state, attrPath, *emptyArgs, *vOutputs); - state.forceValue(*v); + state.forceValue(*v, pos); return {v, pos}; } catch (AttrPathNotFound & e) { } |