forked from lix-project/lix
Attach positions to errors in derivationStrict
(cherry picked from commit 87dc4bc7d139a7eccb257e71558314a0d99e8d6a)
Change-Id: Ib7509cbb1d246ca5aa3607ff860420fe7a754f6a
This commit is contained in:
parent
08252967a8
commit
7eb15e13aa
|
@ -1079,9 +1079,10 @@ drvName, Bindings * attrs, Value & v)
|
||||||
/* Check whether attributes should be passed as a JSON file. */
|
/* Check whether attributes should be passed as a JSON file. */
|
||||||
using nlohmann::json;
|
using nlohmann::json;
|
||||||
std::optional<json> jsonObject;
|
std::optional<json> jsonObject;
|
||||||
|
auto pos = v.determinePos(noPos);
|
||||||
auto attr = attrs->find(state.sStructuredAttrs);
|
auto attr = attrs->find(state.sStructuredAttrs);
|
||||||
if (attr != attrs->end() &&
|
if (attr != attrs->end() &&
|
||||||
state.forceBool(*attr->value, noPos,
|
state.forceBool(*attr->value, pos,
|
||||||
"while evaluating the `__structuredAttrs` "
|
"while evaluating the `__structuredAttrs` "
|
||||||
"attribute passed to builtins.derivationStrict"))
|
"attribute passed to builtins.derivationStrict"))
|
||||||
jsonObject = json::object();
|
jsonObject = json::object();
|
||||||
|
@ -1090,7 +1091,7 @@ drvName, Bindings * attrs, Value & v)
|
||||||
bool ignoreNulls = false;
|
bool ignoreNulls = false;
|
||||||
attr = attrs->find(state.sIgnoreNulls);
|
attr = attrs->find(state.sIgnoreNulls);
|
||||||
if (attr != attrs->end())
|
if (attr != attrs->end())
|
||||||
ignoreNulls = state.forceBool(*attr->value, noPos, "while evaluating the `__ignoreNulls` attribute " "passed to builtins.derivationStrict");
|
ignoreNulls = state.forceBool(*attr->value, pos, "while evaluating the `__ignoreNulls` attribute " "passed to builtins.derivationStrict");
|
||||||
|
|
||||||
/* Build the derivation expression by processing the attributes. */
|
/* Build the derivation expression by processing the attributes. */
|
||||||
Derivation drv;
|
Derivation drv;
|
||||||
|
@ -1154,16 +1155,16 @@ drvName, Bindings * attrs, Value & v)
|
||||||
const std::string_view context_below("");
|
const std::string_view context_below("");
|
||||||
|
|
||||||
if (ignoreNulls) {
|
if (ignoreNulls) {
|
||||||
state.forceValue(*i->value, noPos);
|
state.forceValue(*i->value, pos);
|
||||||
if (i->value->type() == nNull) continue;
|
if (i->value->type() == nNull) continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i->name == state.sContentAddressed && state.forceBool(*i->value, noPos, context_below)) {
|
if (i->name == state.sContentAddressed && state.forceBool(*i->value, pos, context_below)) {
|
||||||
contentAddressed = true;
|
contentAddressed = true;
|
||||||
experimentalFeatureSettings.require(Xp::CaDerivations);
|
experimentalFeatureSettings.require(Xp::CaDerivations);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (i->name == state.sImpure && state.forceBool(*i->value, noPos, context_below)) {
|
else if (i->name == state.sImpure && state.forceBool(*i->value, pos, context_below)) {
|
||||||
isImpure = true;
|
isImpure = true;
|
||||||
experimentalFeatureSettings.require(Xp::ImpureDerivations);
|
experimentalFeatureSettings.require(Xp::ImpureDerivations);
|
||||||
}
|
}
|
||||||
|
@ -1171,9 +1172,9 @@ drvName, Bindings * attrs, Value & v)
|
||||||
/* The `args' attribute is special: it supplies the
|
/* The `args' attribute is special: it supplies the
|
||||||
command-line arguments to the builder. */
|
command-line arguments to the builder. */
|
||||||
else if (i->name == state.sArgs) {
|
else if (i->name == state.sArgs) {
|
||||||
state.forceList(*i->value, noPos, context_below);
|
state.forceList(*i->value, pos, context_below);
|
||||||
for (auto elem : i->value->listItems()) {
|
for (auto elem : i->value->listItems()) {
|
||||||
auto s = state.coerceToString(noPos, *elem, context,
|
auto s = state.coerceToString(pos, *elem, context,
|
||||||
"while evaluating an element of the argument list",
|
"while evaluating an element of the argument list",
|
||||||
true).toOwned();
|
true).toOwned();
|
||||||
drv.args.push_back(s);
|
drv.args.push_back(s);
|
||||||
|
@ -1188,29 +1189,29 @@ drvName, Bindings * attrs, Value & v)
|
||||||
|
|
||||||
if (i->name == state.sStructuredAttrs) continue;
|
if (i->name == state.sStructuredAttrs) continue;
|
||||||
|
|
||||||
(*jsonObject)[key] = printValueAsJSON(state, true, *i->value, noPos, context);
|
(*jsonObject)[key] = printValueAsJSON(state, true, *i->value, pos, context);
|
||||||
|
|
||||||
if (i->name == state.sBuilder)
|
if (i->name == state.sBuilder)
|
||||||
drv.builder = state.forceString(*i->value, context, noPos, context_below);
|
drv.builder = state.forceString(*i->value, context, pos, context_below);
|
||||||
else if (i->name == state.sSystem)
|
else if (i->name == state.sSystem)
|
||||||
drv.platform = state.forceStringNoCtx(*i->value, noPos, context_below);
|
drv.platform = state.forceStringNoCtx(*i->value, pos, context_below);
|
||||||
else if (i->name == state.sOutputHash)
|
else if (i->name == state.sOutputHash)
|
||||||
outputHash = state.forceStringNoCtx(*i->value, noPos, context_below);
|
outputHash = state.forceStringNoCtx(*i->value, pos, context_below);
|
||||||
else if (i->name == state.sOutputHashAlgo)
|
else if (i->name == state.sOutputHashAlgo)
|
||||||
outputHashAlgo = state.forceStringNoCtx(*i->value, noPos, context_below);
|
outputHashAlgo = state.forceStringNoCtx(*i->value, pos, context_below);
|
||||||
else if (i->name == state.sOutputHashMode)
|
else if (i->name == state.sOutputHashMode)
|
||||||
handleHashMode(state.forceStringNoCtx(*i->value, noPos, context_below));
|
handleHashMode(state.forceStringNoCtx(*i->value, pos, context_below));
|
||||||
else if (i->name == state.sOutputs) {
|
else if (i->name == state.sOutputs) {
|
||||||
/* Require ‘outputs’ to be a list of strings. */
|
/* Require ‘outputs’ to be a list of strings. */
|
||||||
state.forceList(*i->value, noPos, context_below);
|
state.forceList(*i->value, pos, context_below);
|
||||||
Strings ss;
|
Strings ss;
|
||||||
for (auto elem : i->value->listItems())
|
for (auto elem : i->value->listItems())
|
||||||
ss.emplace_back(state.forceStringNoCtx(*elem, noPos, context_below));
|
ss.emplace_back(state.forceStringNoCtx(*elem, pos, context_below));
|
||||||
handleOutputs(ss);
|
handleOutputs(ss);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
auto s = state.coerceToString(noPos, *i->value, context, context_below, true).toOwned();
|
auto s = state.coerceToString(pos, *i->value, context, context_below, true).toOwned();
|
||||||
drv.env.emplace(key, s);
|
drv.env.emplace(key, s);
|
||||||
if (i->name == state.sBuilder) drv.builder = std::move(s);
|
if (i->name == state.sBuilder) drv.builder = std::move(s);
|
||||||
else if (i->name == state.sSystem) drv.platform = std::move(s);
|
else if (i->name == state.sSystem) drv.platform = std::move(s);
|
||||||
|
|
Loading…
Reference in a new issue