cmd/libexpr: don't determinePos in value-to-json
it's not useful. nix-instantiate will always point to the wrong location because "at the toplevel" is not a position we can point to. all nesting conversions will point to strange places: the *original* definition of a lambda value (or partial applications thereof), or nowhere at all (since only lambda values can have their positions determined in the formatter) Change-Id: I56bd9e1cf3cae11b4198f148a141ca758e4fe8ac
This commit is contained in:
@@ -51,7 +51,7 @@ void processExpr(EvalState & state, const Strings & attrPaths,
|
||||
if (output == okXML)
|
||||
printValueAsXML(state, strict, location, vRes, std::cout, context, noPos);
|
||||
else if (output == okJSON) {
|
||||
printValueAsJSON(state, strict, vRes, v.determinePos(noPos), std::cout, context);
|
||||
printValueAsJSON(state, strict, vRes, noPos, std::cout, context);
|
||||
std::cout << std::endl;
|
||||
} else {
|
||||
if (strict) state.forceValueDeep(vRes);
|
||||
|
||||
@@ -102,7 +102,7 @@ JSON printValueAsJSON(EvalState & state, bool strict,
|
||||
"cannot convert %1% to JSON",
|
||||
showType(v)
|
||||
)
|
||||
.atPos(v.determinePos(pos))
|
||||
.atPos(pos)
|
||||
.debugThrow();
|
||||
}
|
||||
return out;
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
error:
|
||||
… while calling the 'toJSON' builtin
|
||||
at /pwd/lang/eval-fail-toJSON-nested.nix:1:1:
|
||||
1| builtins.toJSON { foo = a: 1; }
|
||||
| ^
|
||||
2|
|
||||
|
||||
… while evaluating attribute 'foo'
|
||||
at /pwd/lang/eval-fail-toJSON-nested.nix:1:19:
|
||||
1| builtins.toJSON { foo = a: 1; }
|
||||
| ^
|
||||
2|
|
||||
|
||||
error: cannot convert a function to JSON
|
||||
at /pwd/lang/eval-fail-toJSON-nested.nix:1:19:
|
||||
1| builtins.toJSON { foo = a: 1; }
|
||||
| ^
|
||||
2|
|
||||
@@ -0,0 +1 @@
|
||||
builtins.toJSON { foo = a: 1; }
|
||||
Reference in New Issue
Block a user