Merge pull request #9753 from 9999years/print-value-on-type-error

Print the value in `value is X while a Y is expected` error
This commit is contained in:
Robert Hensing 2024-01-22 22:18:16 +01:00 committed by GitHub
commit 5f72a97092
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 227 additions and 136 deletions

View file

@ -0,0 +1,23 @@
---
synopsis: Type errors include the failing value
issues: #561
prs: #9753
---
In errors like `value is an integer while a list was expected`, the message now
includes the failing value.
Before:
```
error: value is a set while a string was expected
```
After:
```
error: expected a string but found a set: { ghc810 = «thunk»;
ghc8102Binary = «thunk»; ghc8107 = «thunk»; ghc8107Binary = «thunk»;
ghc865Binary = «thunk»; ghc90 = «thunk»; ghc902 = «thunk»; ghc92 = «thunk»;
ghc924Binary = «thunk»; ghc925 = «thunk»; «17 attributes elided»}
```

View file

@ -38,5 +38,5 @@ error:
| ^ | ^
5| 5|
error: value is a set while a string was expected error: expected a string but found a set
``` ```

View file

@ -8,7 +8,7 @@ prs: 9658
Previously an incorrect `with` expression would report no position at all, making it hard to determine where the error originated: Previously an incorrect `with` expression would report no position at all, making it hard to determine where the error originated:
``` ```
nix-repl> with 1; a nix-repl> with 1; a
error: error:
<borked> <borked>
@ -27,5 +27,5 @@ error:
1| with 1; a 1| with 1; a
| ^ | ^
error: value is an integer while a set was expected error: expected a set but found an integer
``` ```

View file

@ -1,6 +1,7 @@
#pragma once #pragma once
///@file ///@file
#include "print.hh"
#include "eval.hh" #include "eval.hh"
namespace nix { namespace nix {
@ -114,7 +115,10 @@ inline void EvalState::forceAttrs(Value & v, Callable getPos, std::string_view e
PosIdx pos = getPos(); PosIdx pos = getPos();
forceValue(v, pos); forceValue(v, pos);
if (v.type() != nAttrs) { if (v.type() != nAttrs) {
error("value is %1% while a set was expected", showType(v)).withTrace(pos, errorCtx).debugThrow<TypeError>(); error("expected a set but found %1%: %2%",
showType(v),
ValuePrinter(*this, v, errorPrintOptions))
.withTrace(pos, errorCtx).debugThrow<TypeError>();
} }
} }
@ -124,7 +128,10 @@ inline void EvalState::forceList(Value & v, const PosIdx pos, std::string_view e
{ {
forceValue(v, pos); forceValue(v, pos);
if (!v.isList()) { if (!v.isList()) {
error("value is %1% while a list was expected", showType(v)).withTrace(pos, errorCtx).debugThrow<TypeError>(); error("expected a list but found %1%: %2%",
showType(v),
ValuePrinter(*this, v, errorPrintOptions))
.withTrace(pos, errorCtx).debugThrow<TypeError>();
} }
} }

View file

@ -2,6 +2,7 @@
#include "eval-settings.hh" #include "eval-settings.hh"
#include "hash.hh" #include "hash.hh"
#include "primops.hh" #include "primops.hh"
#include "print-options.hh"
#include "types.hh" #include "types.hh"
#include "util.hh" #include "util.hh"
#include "store-api.hh" #include "store-api.hh"
@ -29,9 +30,9 @@
#include <unistd.h> #include <unistd.h>
#include <sys/time.h> #include <sys/time.h>
#include <sys/resource.h> #include <sys/resource.h>
#include <iostream>
#include <fstream> #include <fstream>
#include <functional> #include <functional>
#include <iostream>
#include <sys/resource.h> #include <sys/resource.h>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
@ -1153,7 +1154,10 @@ inline bool EvalState::evalBool(Env & env, Expr * e, const PosIdx pos, std::stri
Value v; Value v;
e->eval(*this, env, v); e->eval(*this, env, v);
if (v.type() != nBool) if (v.type() != nBool)
error("value is %1% while a Boolean was expected", showType(v)).withFrame(env, *e).debugThrow<TypeError>(); error("expected a Boolean but found %1%: %2%",
showType(v),
ValuePrinter(*this, v, errorPrintOptions))
.withFrame(env, *e).debugThrow<TypeError>();
return v.boolean; return v.boolean;
} catch (Error & e) { } catch (Error & e) {
e.addTrace(positions[pos], errorCtx); e.addTrace(positions[pos], errorCtx);
@ -1167,7 +1171,10 @@ inline void EvalState::evalAttrs(Env & env, Expr * e, Value & v, const PosIdx po
try { try {
e->eval(*this, env, v); e->eval(*this, env, v);
if (v.type() != nAttrs) if (v.type() != nAttrs)
error("value is %1% while a set was expected", showType(v)).withFrame(env, *e).debugThrow<TypeError>(); error("expected a set but found %1%: %2%",
showType(v),
ValuePrinter(*this, v, errorPrintOptions))
.withFrame(env, *e).debugThrow<TypeError>();
} catch (Error & e) { } catch (Error & e) {
e.addTrace(positions[pos], errorCtx); e.addTrace(positions[pos], errorCtx);
throw; throw;
@ -2076,7 +2083,10 @@ NixInt EvalState::forceInt(Value & v, const PosIdx pos, std::string_view errorCt
try { try {
forceValue(v, pos); forceValue(v, pos);
if (v.type() != nInt) if (v.type() != nInt)
error("value is %1% while an integer was expected", showType(v)).debugThrow<TypeError>(); error("expected an integer but found %1%: %2%",
showType(v),
ValuePrinter(*this, v, errorPrintOptions))
.debugThrow<TypeError>();
return v.integer; return v.integer;
} catch (Error & e) { } catch (Error & e) {
e.addTrace(positions[pos], errorCtx); e.addTrace(positions[pos], errorCtx);
@ -2092,7 +2102,10 @@ NixFloat EvalState::forceFloat(Value & v, const PosIdx pos, std::string_view err
if (v.type() == nInt) if (v.type() == nInt)
return v.integer; return v.integer;
else if (v.type() != nFloat) else if (v.type() != nFloat)
error("value is %1% while a float was expected", showType(v)).debugThrow<TypeError>(); error("expected a float but found %1%: %2%",
showType(v),
ValuePrinter(*this, v, errorPrintOptions))
.debugThrow<TypeError>();
return v.fpoint; return v.fpoint;
} catch (Error & e) { } catch (Error & e) {
e.addTrace(positions[pos], errorCtx); e.addTrace(positions[pos], errorCtx);
@ -2106,7 +2119,10 @@ bool EvalState::forceBool(Value & v, const PosIdx pos, std::string_view errorCtx
try { try {
forceValue(v, pos); forceValue(v, pos);
if (v.type() != nBool) if (v.type() != nBool)
error("value is %1% while a Boolean was expected", showType(v)).debugThrow<TypeError>(); error("expected a Boolean but found %1%: %2%",
showType(v),
ValuePrinter(*this, v, errorPrintOptions))
.debugThrow<TypeError>();
return v.boolean; return v.boolean;
} catch (Error & e) { } catch (Error & e) {
e.addTrace(positions[pos], errorCtx); e.addTrace(positions[pos], errorCtx);
@ -2126,7 +2142,10 @@ void EvalState::forceFunction(Value & v, const PosIdx pos, std::string_view erro
try { try {
forceValue(v, pos); forceValue(v, pos);
if (v.type() != nFunction && !isFunctor(v)) if (v.type() != nFunction && !isFunctor(v))
error("value is %1% while a function was expected", showType(v)).debugThrow<TypeError>(); error("expected a function but found %1%: %2%",
showType(v),
ValuePrinter(*this, v, errorPrintOptions))
.debugThrow<TypeError>();
} catch (Error & e) { } catch (Error & e) {
e.addTrace(positions[pos], errorCtx); e.addTrace(positions[pos], errorCtx);
throw; throw;
@ -2139,7 +2158,10 @@ std::string_view EvalState::forceString(Value & v, const PosIdx pos, std::string
try { try {
forceValue(v, pos); forceValue(v, pos);
if (v.type() != nString) if (v.type() != nString)
error("value is %1% while a string was expected", showType(v)).debugThrow<TypeError>(); error("expected a string but found %1%: %2%",
showType(v),
ValuePrinter(*this, v, errorPrintOptions))
.debugThrow<TypeError>();
return v.string_view(); return v.string_view();
} catch (Error & e) { } catch (Error & e) {
e.addTrace(positions[pos], errorCtx); e.addTrace(positions[pos], errorCtx);

View file

@ -997,7 +997,7 @@ static void prim_trace(EvalState & state, const PosIdx pos, Value * * args, Valu
if (args[0]->type() == nString) if (args[0]->type() == nString)
printError("trace: %1%", args[0]->string_view()); printError("trace: %1%", args[0]->string_view());
else else
printError("trace: %1%", printValue(state, *args[0])); printError("trace: %1%", ValuePrinter(state, *args[0]));
state.forceValue(*args[1], pos); state.forceValue(*args[1], pos);
v = *args[1]; v = *args[1];
} }

View file

@ -1,6 +1,7 @@
#include "print-ambiguous.hh" #include "print-ambiguous.hh"
#include "print.hh" #include "print.hh"
#include "signals.hh" #include "signals.hh"
#include "eval.hh"
namespace nix { namespace nix {

View file

@ -49,4 +49,16 @@ struct PrintOptions
size_t maxStringLength = std::numeric_limits<size_t>::max(); size_t maxStringLength = std::numeric_limits<size_t>::max();
}; };
/**
* `PrintOptions` for unknown and therefore potentially large values in error messages,
* to avoid printing "too much" output.
*/
static PrintOptions errorPrintOptions = PrintOptions {
.ansiColors = true,
.maxDepth = 10,
.maxAttrs = 10,
.maxListItems = 10,
.maxStringLength = 1024
};
} }

View file

@ -7,6 +7,7 @@
#include "store-api.hh" #include "store-api.hh"
#include "terminal.hh" #include "terminal.hh"
#include "english.hh" #include "english.hh"
#include "eval.hh"
namespace nix { namespace nix {
@ -501,4 +502,10 @@ void printValue(EvalState & state, std::ostream & output, Value & v, PrintOption
Printer(output, state, options).print(v); Printer(output, state, options).print(v);
} }
std::ostream & operator<<(std::ostream & output, const ValuePrinter & printer)
{
printValue(printer.state, output, printer.value, printer.options);
return output;
}
} }

View file

@ -9,11 +9,13 @@
#include <iostream> #include <iostream>
#include "eval.hh"
#include "print-options.hh" #include "print-options.hh"
namespace nix { namespace nix {
class EvalState;
struct Value;
/** /**
* Print a string as a Nix string literal. * Print a string as a Nix string literal.
* *
@ -59,4 +61,21 @@ std::ostream & printIdentifier(std::ostream & o, std::string_view s);
void printValue(EvalState & state, std::ostream & str, Value & v, PrintOptions options = PrintOptions {}); void printValue(EvalState & state, std::ostream & str, Value & v, PrintOptions options = PrintOptions {});
/**
* A partially-applied form of `printValue` which can be formatted using `<<`
* without allocating an intermediate string.
*/
class ValuePrinter {
friend std::ostream & operator << (std::ostream & output, const ValuePrinter & printer);
private:
EvalState & state;
Value & value;
PrintOptions options;
public:
ValuePrinter(EvalState & state, Value & value, PrintOptions options = PrintOptions {})
: state(state), value(value), options(options) { }
};
std::ostream & operator<<(std::ostream & output, const ValuePrinter & printer);
} }

View file

@ -335,7 +335,7 @@ std::ostream & showErrorInfo(std::ostream & out, const ErrorInfo & einfo, bool s
* try { * try {
* e->eval(*this, env, v); * e->eval(*this, env, v);
* if (v.type() != nAttrs) * if (v.type() != nAttrs)
* throwTypeError("value is %1% while a set was expected", v); * throwTypeError("expected a set but found %1%", v);
* } catch (Error & e) { * } catch (Error & e) {
* e.addTrace(pos, errorCtx); * e.addTrace(pos, errorCtx);
* throw; * throw;
@ -349,7 +349,7 @@ std::ostream & showErrorInfo(std::ostream & out, const ErrorInfo & einfo, bool s
* e->eval(*this, env, v); * e->eval(*this, env, v);
* try { * try {
* if (v.type() != nAttrs) * if (v.type() != nAttrs)
* throwTypeError("value is %1% while a set was expected", v); * throwTypeError("expected a set but found %1%", v);
* } catch (Error & e) { * } catch (Error & e) {
* e.addTrace(pos, errorCtx); * e.addTrace(pos, errorCtx);
* throw; * throw;

View file

@ -121,7 +121,7 @@ struct CmdEval : MixJSON, InstallableValueCommand, MixReadOnlyOption
else { else {
state->forceValueDeep(*v); state->forceValueDeep(*v);
logger->cout("%s", printValue(*state, *v)); logger->cout("%s", ValuePrinter(*state, *v, PrintOptions { .force = true }));
} }
} }
}; };

View file

@ -14,7 +14,7 @@ nix --experimental-features 'nix-command' eval --impure --expr \
# resolve first. Adding a test so we don't liberalise it by accident. # resolve first. Adding a test so we don't liberalise it by accident.
expectStderr 1 nix --experimental-features 'nix-command dynamic-derivations' eval --impure --expr \ expectStderr 1 nix --experimental-features 'nix-command dynamic-derivations' eval --impure --expr \
'builtins.outputOf (import ../dependencies.nix {}) "out"' \ 'builtins.outputOf (import ../dependencies.nix {}) "out"' \
| grepQuiet "value is a set while a string was expected" | grepQuiet "expected a string but found a set"
# Test that "DrvDeep" string contexts are not supported at this time # Test that "DrvDeep" string contexts are not supported at this time
# #

View file

@ -13,4 +13,4 @@ error:
| ^ | ^
8| 8|
error: value is an integer while a string was expected error: expected a string but found an integer: 1

View file

@ -7,4 +7,4 @@ error:
… while evaluating the first argument passed to builtins.length … while evaluating the first argument passed to builtins.length
error: value is an integer while a list was expected error: expected a list but found an integer: 1

View file

@ -5,4 +5,4 @@ error:
| ^ | ^
2| 2|
error: value is an integer while a list was expected error: expected a list but found an integer: 8

View file

@ -1,4 +1,4 @@
error: error:
… while evaluating the `__overrides` attribute … while evaluating the `__overrides` attribute
error: value is an integer while a set was expected error: expected a set but found an integer: 1

View file

@ -6,4 +6,4 @@ error:
| ^ | ^
6| 6|
error: value is a set while a string was expected error: expected a string but found a set: { }

View file

@ -105,7 +105,7 @@ namespace nix {
TEST_F(ErrorTraceTest, genericClosure) { TEST_F(ErrorTraceTest, genericClosure) {
ASSERT_TRACE2("genericClosure 1", ASSERT_TRACE2("genericClosure 1",
TypeError, TypeError,
hintfmt("value is %s while a set was expected", "an integer"), hintfmt("expected a set but found %s: %s", "an integer", ANSI_CYAN "1" ANSI_NORMAL),
hintfmt("while evaluating the first argument passed to builtins.genericClosure")); hintfmt("while evaluating the first argument passed to builtins.genericClosure"));
ASSERT_TRACE2("genericClosure {}", ASSERT_TRACE2("genericClosure {}",
@ -115,22 +115,22 @@ namespace nix {
ASSERT_TRACE2("genericClosure { startSet = 1; }", ASSERT_TRACE2("genericClosure { startSet = 1; }",
TypeError, TypeError,
hintfmt("value is %s while a list was expected", "an integer"), hintfmt("expected a list but found %s: %s", "an integer", ANSI_CYAN "1" ANSI_NORMAL),
hintfmt("while evaluating the 'startSet' attribute passed as argument to builtins.genericClosure")); hintfmt("while evaluating the 'startSet' attribute passed as argument to builtins.genericClosure"));
ASSERT_TRACE2("genericClosure { startSet = [{ key = 1;}]; operator = true; }", ASSERT_TRACE2("genericClosure { startSet = [{ key = 1;}]; operator = true; }",
TypeError, TypeError,
hintfmt("value is %s while a function was expected", "a Boolean"), hintfmt("expected a function but found %s: %s", "a Boolean", ANSI_CYAN "true" ANSI_NORMAL),
hintfmt("while evaluating the 'operator' attribute passed as argument to builtins.genericClosure")); hintfmt("while evaluating the 'operator' attribute passed as argument to builtins.genericClosure"));
ASSERT_TRACE2("genericClosure { startSet = [{ key = 1;}]; operator = item: true; }", ASSERT_TRACE2("genericClosure { startSet = [{ key = 1;}]; operator = item: true; }",
TypeError, TypeError,
hintfmt("value is %s while a list was expected", "a Boolean"), hintfmt("expected a list but found %s: %s", "a Boolean", ANSI_CYAN "true" ANSI_NORMAL),
hintfmt("while evaluating the return value of the `operator` passed to builtins.genericClosure")); hintfmt("while evaluating the return value of the `operator` passed to builtins.genericClosure"));
ASSERT_TRACE2("genericClosure { startSet = [{ key = 1;}]; operator = item: [ true ]; }", ASSERT_TRACE2("genericClosure { startSet = [{ key = 1;}]; operator = item: [ true ]; }",
TypeError, TypeError,
hintfmt("value is %s while a set was expected", "a Boolean"), hintfmt("expected a set but found %s: %s", "a Boolean", ANSI_CYAN "true" ANSI_NORMAL),
hintfmt("while evaluating one of the elements generated by (or initially passed to) builtins.genericClosure")); hintfmt("while evaluating one of the elements generated by (or initially passed to) builtins.genericClosure"));
ASSERT_TRACE2("genericClosure { startSet = [{ key = 1;}]; operator = item: [ {} ]; }", ASSERT_TRACE2("genericClosure { startSet = [{ key = 1;}]; operator = item: [ {} ]; }",
@ -145,7 +145,7 @@ namespace nix {
ASSERT_TRACE2("genericClosure { startSet = [ true ]; operator = item: [{ key = ''a''; }]; }", ASSERT_TRACE2("genericClosure { startSet = [ true ]; operator = item: [{ key = ''a''; }]; }",
TypeError, TypeError,
hintfmt("value is %s while a set was expected", "a Boolean"), hintfmt("expected a set but found %s: %s", "a Boolean", ANSI_CYAN "true" ANSI_NORMAL),
hintfmt("while evaluating one of the elements generated by (or initially passed to) builtins.genericClosure")); hintfmt("while evaluating one of the elements generated by (or initially passed to) builtins.genericClosure"));
} }
@ -154,12 +154,12 @@ namespace nix {
TEST_F(ErrorTraceTest, replaceStrings) { TEST_F(ErrorTraceTest, replaceStrings) {
ASSERT_TRACE2("replaceStrings 0 0 {}", ASSERT_TRACE2("replaceStrings 0 0 {}",
TypeError, TypeError,
hintfmt("value is %s while a list was expected", "an integer"), hintfmt("expected a list but found %s: %s", "an integer", ANSI_CYAN "0" ANSI_NORMAL),
hintfmt("while evaluating the first argument passed to builtins.replaceStrings")); hintfmt("while evaluating the first argument passed to builtins.replaceStrings"));
ASSERT_TRACE2("replaceStrings [] 0 {}", ASSERT_TRACE2("replaceStrings [] 0 {}",
TypeError, TypeError,
hintfmt("value is %s while a list was expected", "an integer"), hintfmt("expected a list but found %s: %s", "an integer", ANSI_CYAN "0" ANSI_NORMAL),
hintfmt("while evaluating the second argument passed to builtins.replaceStrings")); hintfmt("while evaluating the second argument passed to builtins.replaceStrings"));
ASSERT_TRACE1("replaceStrings [ 0 ] [] {}", ASSERT_TRACE1("replaceStrings [ 0 ] [] {}",
@ -168,17 +168,17 @@ namespace nix {
ASSERT_TRACE2("replaceStrings [ 1 ] [ \"new\" ] {}", ASSERT_TRACE2("replaceStrings [ 1 ] [ \"new\" ] {}",
TypeError, TypeError,
hintfmt("value is %s while a string was expected", "an integer"), hintfmt("expected a string but found %s: %s", "an integer", ANSI_CYAN "1" ANSI_NORMAL),
hintfmt("while evaluating one of the strings to replace passed to builtins.replaceStrings")); hintfmt("while evaluating one of the strings to replace passed to builtins.replaceStrings"));
ASSERT_TRACE2("replaceStrings [ \"oo\" ] [ true ] \"foo\"", ASSERT_TRACE2("replaceStrings [ \"oo\" ] [ true ] \"foo\"",
TypeError, TypeError,
hintfmt("value is %s while a string was expected", "a Boolean"), hintfmt("expected a string but found %s: %s", "a Boolean", ANSI_CYAN "true" ANSI_NORMAL),
hintfmt("while evaluating one of the replacement strings passed to builtins.replaceStrings")); hintfmt("while evaluating one of the replacement strings passed to builtins.replaceStrings"));
ASSERT_TRACE2("replaceStrings [ \"old\" ] [ \"new\" ] {}", ASSERT_TRACE2("replaceStrings [ \"old\" ] [ \"new\" ] {}",
TypeError, TypeError,
hintfmt("value is %s while a string was expected", "a set"), hintfmt("expected a string but found %s: %s", "a set", "{ }"),
hintfmt("while evaluating the third argument passed to builtins.replaceStrings")); hintfmt("while evaluating the third argument passed to builtins.replaceStrings"));
} }
@ -243,7 +243,7 @@ namespace nix {
TEST_F(ErrorTraceTest, ceil) { TEST_F(ErrorTraceTest, ceil) {
ASSERT_TRACE2("ceil \"foo\"", ASSERT_TRACE2("ceil \"foo\"",
TypeError, TypeError,
hintfmt("value is %s while a float was expected", "a string"), hintfmt("expected a float but found %s: %s", "a string", ANSI_MAGENTA "\"foo\"" ANSI_NORMAL),
hintfmt("while evaluating the first argument passed to builtins.ceil")); hintfmt("while evaluating the first argument passed to builtins.ceil"));
} }
@ -252,7 +252,7 @@ namespace nix {
TEST_F(ErrorTraceTest, floor) { TEST_F(ErrorTraceTest, floor) {
ASSERT_TRACE2("floor \"foo\"", ASSERT_TRACE2("floor \"foo\"",
TypeError, TypeError,
hintfmt("value is %s while a float was expected", "a string"), hintfmt("expected a float but found %s: %s", "a string", ANSI_MAGENTA "\"foo\"" ANSI_NORMAL),
hintfmt("while evaluating the first argument passed to builtins.floor")); hintfmt("while evaluating the first argument passed to builtins.floor"));
} }
@ -265,7 +265,7 @@ namespace nix {
TEST_F(ErrorTraceTest, getEnv) { TEST_F(ErrorTraceTest, getEnv) {
ASSERT_TRACE2("getEnv [ ]", ASSERT_TRACE2("getEnv [ ]",
TypeError, TypeError,
hintfmt("value is %s while a string was expected", "a list"), hintfmt("expected a string but found %s: %s", "a list", "[ ]"),
hintfmt("while evaluating the first argument passed to builtins.getEnv")); hintfmt("while evaluating the first argument passed to builtins.getEnv"));
} }
@ -286,7 +286,7 @@ namespace nix {
TEST_F(ErrorTraceTest, placeholder) { TEST_F(ErrorTraceTest, placeholder) {
ASSERT_TRACE2("placeholder []", ASSERT_TRACE2("placeholder []",
TypeError, TypeError,
hintfmt("value is %s while a string was expected", "a list"), hintfmt("expected a string but found %s: %s", "a list", "[ ]"),
hintfmt("while evaluating the first argument passed to builtins.placeholder")); hintfmt("while evaluating the first argument passed to builtins.placeholder"));
} }
@ -387,7 +387,7 @@ namespace nix {
ASSERT_TRACE2("filterSource [] ./.", ASSERT_TRACE2("filterSource [] ./.",
TypeError, TypeError,
hintfmt("value is %s while a function was expected", "a list"), hintfmt("expected a function but found %s: %s", "a list", "[ ]"),
hintfmt("while evaluating the first argument passed to builtins.filterSource")); hintfmt("while evaluating the first argument passed to builtins.filterSource"));
// Usupported by store "dummy" // Usupported by store "dummy"
@ -399,7 +399,7 @@ namespace nix {
// ASSERT_TRACE2("filterSource (_: _: 1) ./.", // ASSERT_TRACE2("filterSource (_: _: 1) ./.",
// TypeError, // TypeError,
// hintfmt("value is %s while a Boolean was expected", "an integer"), // hintfmt("expected a Boolean but found %s: %s", "an integer", "1"),
// hintfmt("while evaluating the return value of the path filter function")); // hintfmt("while evaluating the return value of the path filter function"));
} }
@ -412,7 +412,7 @@ namespace nix {
TEST_F(ErrorTraceTest, attrNames) { TEST_F(ErrorTraceTest, attrNames) {
ASSERT_TRACE2("attrNames []", ASSERT_TRACE2("attrNames []",
TypeError, TypeError,
hintfmt("value is %s while a set was expected", "a list"), hintfmt("expected a set but found %s: %s", "a list", "[ ]"),
hintfmt("while evaluating the argument passed to builtins.attrNames")); hintfmt("while evaluating the argument passed to builtins.attrNames"));
} }
@ -421,7 +421,7 @@ namespace nix {
TEST_F(ErrorTraceTest, attrValues) { TEST_F(ErrorTraceTest, attrValues) {
ASSERT_TRACE2("attrValues []", ASSERT_TRACE2("attrValues []",
TypeError, TypeError,
hintfmt("value is %s while a set was expected", "a list"), hintfmt("expected a set but found %s: %s", "a list", "[ ]"),
hintfmt("while evaluating the argument passed to builtins.attrValues")); hintfmt("while evaluating the argument passed to builtins.attrValues"));
} }
@ -430,12 +430,12 @@ namespace nix {
TEST_F(ErrorTraceTest, getAttr) { TEST_F(ErrorTraceTest, getAttr) {
ASSERT_TRACE2("getAttr [] []", ASSERT_TRACE2("getAttr [] []",
TypeError, TypeError,
hintfmt("value is %s while a string was expected", "a list"), hintfmt("expected a string but found %s: %s", "a list", "[ ]"),
hintfmt("while evaluating the first argument passed to builtins.getAttr")); hintfmt("while evaluating the first argument passed to builtins.getAttr"));
ASSERT_TRACE2("getAttr \"foo\" []", ASSERT_TRACE2("getAttr \"foo\" []",
TypeError, TypeError,
hintfmt("value is %s while a set was expected", "a list"), hintfmt("expected a set but found %s: %s", "a list", "[ ]"),
hintfmt("while evaluating the second argument passed to builtins.getAttr")); hintfmt("while evaluating the second argument passed to builtins.getAttr"));
ASSERT_TRACE2("getAttr \"foo\" {}", ASSERT_TRACE2("getAttr \"foo\" {}",
@ -453,12 +453,12 @@ namespace nix {
TEST_F(ErrorTraceTest, hasAttr) { TEST_F(ErrorTraceTest, hasAttr) {
ASSERT_TRACE2("hasAttr [] []", ASSERT_TRACE2("hasAttr [] []",
TypeError, TypeError,
hintfmt("value is %s while a string was expected", "a list"), hintfmt("expected a string but found %s: %s", "a list", "[ ]"),
hintfmt("while evaluating the first argument passed to builtins.hasAttr")); hintfmt("while evaluating the first argument passed to builtins.hasAttr"));
ASSERT_TRACE2("hasAttr \"foo\" []", ASSERT_TRACE2("hasAttr \"foo\" []",
TypeError, TypeError,
hintfmt("value is %s while a set was expected", "a list"), hintfmt("expected a set but found %s: %s", "a list", "[ ]"),
hintfmt("while evaluating the second argument passed to builtins.hasAttr")); hintfmt("while evaluating the second argument passed to builtins.hasAttr"));
} }
@ -471,17 +471,17 @@ namespace nix {
TEST_F(ErrorTraceTest, removeAttrs) { TEST_F(ErrorTraceTest, removeAttrs) {
ASSERT_TRACE2("removeAttrs \"\" \"\"", ASSERT_TRACE2("removeAttrs \"\" \"\"",
TypeError, TypeError,
hintfmt("value is %s while a set was expected", "a string"), hintfmt("expected a set but found %s: %s", "a string", ANSI_MAGENTA "\"\"" ANSI_NORMAL),
hintfmt("while evaluating the first argument passed to builtins.removeAttrs")); hintfmt("while evaluating the first argument passed to builtins.removeAttrs"));
ASSERT_TRACE2("removeAttrs \"\" [ 1 ]", ASSERT_TRACE2("removeAttrs \"\" [ 1 ]",
TypeError, TypeError,
hintfmt("value is %s while a set was expected", "a string"), hintfmt("expected a set but found %s: %s", "a string", ANSI_MAGENTA "\"\"" ANSI_NORMAL),
hintfmt("while evaluating the first argument passed to builtins.removeAttrs")); hintfmt("while evaluating the first argument passed to builtins.removeAttrs"));
ASSERT_TRACE2("removeAttrs \"\" [ \"1\" ]", ASSERT_TRACE2("removeAttrs \"\" [ \"1\" ]",
TypeError, TypeError,
hintfmt("value is %s while a set was expected", "a string"), hintfmt("expected a set but found %s: %s", "a string", ANSI_MAGENTA "\"\"" ANSI_NORMAL),
hintfmt("while evaluating the first argument passed to builtins.removeAttrs")); hintfmt("while evaluating the first argument passed to builtins.removeAttrs"));
} }
@ -490,12 +490,12 @@ namespace nix {
TEST_F(ErrorTraceTest, listToAttrs) { TEST_F(ErrorTraceTest, listToAttrs) {
ASSERT_TRACE2("listToAttrs 1", ASSERT_TRACE2("listToAttrs 1",
TypeError, TypeError,
hintfmt("value is %s while a list was expected", "an integer"), hintfmt("expected a list but found %s: %s", "an integer", ANSI_CYAN "1" ANSI_NORMAL),
hintfmt("while evaluating the argument passed to builtins.listToAttrs")); hintfmt("while evaluating the argument passed to builtins.listToAttrs"));
ASSERT_TRACE2("listToAttrs [ 1 ]", ASSERT_TRACE2("listToAttrs [ 1 ]",
TypeError, TypeError,
hintfmt("value is %s while a set was expected", "an integer"), hintfmt("expected a set but found %s: %s", "an integer", ANSI_CYAN "1" ANSI_NORMAL),
hintfmt("while evaluating an element of the list passed to builtins.listToAttrs")); hintfmt("while evaluating an element of the list passed to builtins.listToAttrs"));
ASSERT_TRACE2("listToAttrs [ {} ]", ASSERT_TRACE2("listToAttrs [ {} ]",
@ -505,7 +505,7 @@ namespace nix {
ASSERT_TRACE2("listToAttrs [ { name = 1; } ]", ASSERT_TRACE2("listToAttrs [ { name = 1; } ]",
TypeError, TypeError,
hintfmt("value is %s while a string was expected", "an integer"), hintfmt("expected a string but found %s: %s", "an integer", ANSI_CYAN "1" ANSI_NORMAL),
hintfmt("while evaluating the `name` attribute of an element of the list passed to builtins.listToAttrs")); hintfmt("while evaluating the `name` attribute of an element of the list passed to builtins.listToAttrs"));
ASSERT_TRACE2("listToAttrs [ { name = \"foo\"; } ]", ASSERT_TRACE2("listToAttrs [ { name = \"foo\"; } ]",
@ -519,12 +519,12 @@ namespace nix {
TEST_F(ErrorTraceTest, intersectAttrs) { TEST_F(ErrorTraceTest, intersectAttrs) {
ASSERT_TRACE2("intersectAttrs [] []", ASSERT_TRACE2("intersectAttrs [] []",
TypeError, TypeError,
hintfmt("value is %s while a set was expected", "a list"), hintfmt("expected a set but found %s: %s", "a list", "[ ]"),
hintfmt("while evaluating the first argument passed to builtins.intersectAttrs")); hintfmt("while evaluating the first argument passed to builtins.intersectAttrs"));
ASSERT_TRACE2("intersectAttrs {} []", ASSERT_TRACE2("intersectAttrs {} []",
TypeError, TypeError,
hintfmt("value is %s while a set was expected", "a list"), hintfmt("expected a set but found %s: %s", "a list", "[ ]"),
hintfmt("while evaluating the second argument passed to builtins.intersectAttrs")); hintfmt("while evaluating the second argument passed to builtins.intersectAttrs"));
} }
@ -533,22 +533,22 @@ namespace nix {
TEST_F(ErrorTraceTest, catAttrs) { TEST_F(ErrorTraceTest, catAttrs) {
ASSERT_TRACE2("catAttrs [] {}", ASSERT_TRACE2("catAttrs [] {}",
TypeError, TypeError,
hintfmt("value is %s while a string was expected", "a list"), hintfmt("expected a string but found %s: %s", "a list", "[ ]"),
hintfmt("while evaluating the first argument passed to builtins.catAttrs")); hintfmt("while evaluating the first argument passed to builtins.catAttrs"));
ASSERT_TRACE2("catAttrs \"foo\" {}", ASSERT_TRACE2("catAttrs \"foo\" {}",
TypeError, TypeError,
hintfmt("value is %s while a list was expected", "a set"), hintfmt("expected a list but found %s: %s", "a set", "{ }"),
hintfmt("while evaluating the second argument passed to builtins.catAttrs")); hintfmt("while evaluating the second argument passed to builtins.catAttrs"));
ASSERT_TRACE2("catAttrs \"foo\" [ 1 ]", ASSERT_TRACE2("catAttrs \"foo\" [ 1 ]",
TypeError, TypeError,
hintfmt("value is %s while a set was expected", "an integer"), hintfmt("expected a set but found %s: %s", "an integer", ANSI_CYAN "1" ANSI_NORMAL),
hintfmt("while evaluating an element in the list passed as second argument to builtins.catAttrs")); hintfmt("while evaluating an element in the list passed as second argument to builtins.catAttrs"));
ASSERT_TRACE2("catAttrs \"foo\" [ { foo = 1; } 1 { bar = 5;} ]", ASSERT_TRACE2("catAttrs \"foo\" [ { foo = 1; } 1 { bar = 5;} ]",
TypeError, TypeError,
hintfmt("value is %s while a set was expected", "an integer"), hintfmt("expected a set but found %s: %s", "an integer", ANSI_CYAN "1" ANSI_NORMAL),
hintfmt("while evaluating an element in the list passed as second argument to builtins.catAttrs")); hintfmt("while evaluating an element in the list passed as second argument to builtins.catAttrs"));
} }
@ -565,7 +565,7 @@ namespace nix {
TEST_F(ErrorTraceTest, mapAttrs) { TEST_F(ErrorTraceTest, mapAttrs) {
ASSERT_TRACE2("mapAttrs [] []", ASSERT_TRACE2("mapAttrs [] []",
TypeError, TypeError,
hintfmt("value is %s while a set was expected", "a list"), hintfmt("expected a set but found %s: %s", "a list", "[ ]"),
hintfmt("while evaluating the second argument passed to builtins.mapAttrs")); hintfmt("while evaluating the second argument passed to builtins.mapAttrs"));
// XXX: defered // XXX: defered
@ -590,12 +590,12 @@ namespace nix {
TEST_F(ErrorTraceTest, zipAttrsWith) { TEST_F(ErrorTraceTest, zipAttrsWith) {
ASSERT_TRACE2("zipAttrsWith [] [ 1 ]", ASSERT_TRACE2("zipAttrsWith [] [ 1 ]",
TypeError, TypeError,
hintfmt("value is %s while a function was expected", "a list"), hintfmt("expected a function but found %s: %s", "a list", "[ ]"),
hintfmt("while evaluating the first argument passed to builtins.zipAttrsWith")); hintfmt("while evaluating the first argument passed to builtins.zipAttrsWith"));
ASSERT_TRACE2("zipAttrsWith (_: 1) [ 1 ]", ASSERT_TRACE2("zipAttrsWith (_: 1) [ 1 ]",
TypeError, TypeError,
hintfmt("value is %s while a set was expected", "an integer"), hintfmt("expected a set but found %s: %s", "an integer", ANSI_CYAN "1" ANSI_NORMAL),
hintfmt("while evaluating a value of the list passed as second argument to builtins.zipAttrsWith")); hintfmt("while evaluating a value of the list passed as second argument to builtins.zipAttrsWith"));
// XXX: How to properly tell that the fucntion takes two arguments ? // XXX: How to properly tell that the fucntion takes two arguments ?
@ -622,7 +622,7 @@ namespace nix {
TEST_F(ErrorTraceTest, elemAt) { TEST_F(ErrorTraceTest, elemAt) {
ASSERT_TRACE2("elemAt \"foo\" (-1)", ASSERT_TRACE2("elemAt \"foo\" (-1)",
TypeError, TypeError,
hintfmt("value is %s while a list was expected", "a string"), hintfmt("expected a list but found %s: %s", "a string", ANSI_MAGENTA "\"foo\"" ANSI_NORMAL),
hintfmt("while evaluating the first argument passed to builtins.elemAt")); hintfmt("while evaluating the first argument passed to builtins.elemAt"));
ASSERT_TRACE1("elemAt [] (-1)", ASSERT_TRACE1("elemAt [] (-1)",
@ -639,7 +639,7 @@ namespace nix {
TEST_F(ErrorTraceTest, head) { TEST_F(ErrorTraceTest, head) {
ASSERT_TRACE2("head 1", ASSERT_TRACE2("head 1",
TypeError, TypeError,
hintfmt("value is %s while a list was expected", "an integer"), hintfmt("expected a list but found %s: %s", "an integer", ANSI_CYAN "1" ANSI_NORMAL),
hintfmt("while evaluating the first argument passed to builtins.elemAt")); hintfmt("while evaluating the first argument passed to builtins.elemAt"));
ASSERT_TRACE1("head []", ASSERT_TRACE1("head []",
@ -652,7 +652,7 @@ namespace nix {
TEST_F(ErrorTraceTest, tail) { TEST_F(ErrorTraceTest, tail) {
ASSERT_TRACE2("tail 1", ASSERT_TRACE2("tail 1",
TypeError, TypeError,
hintfmt("value is %s while a list was expected", "an integer"), hintfmt("expected a list but found %s: %s", "an integer", ANSI_CYAN "1" ANSI_NORMAL),
hintfmt("while evaluating the first argument passed to builtins.tail")); hintfmt("while evaluating the first argument passed to builtins.tail"));
ASSERT_TRACE1("tail []", ASSERT_TRACE1("tail []",
@ -665,12 +665,12 @@ namespace nix {
TEST_F(ErrorTraceTest, map) { TEST_F(ErrorTraceTest, map) {
ASSERT_TRACE2("map 1 \"foo\"", ASSERT_TRACE2("map 1 \"foo\"",
TypeError, TypeError,
hintfmt("value is %s while a list was expected", "a string"), hintfmt("expected a list but found %s: %s", "a string", ANSI_MAGENTA "\"foo\"" ANSI_NORMAL),
hintfmt("while evaluating the second argument passed to builtins.map")); hintfmt("while evaluating the second argument passed to builtins.map"));
ASSERT_TRACE2("map 1 [ 1 ]", ASSERT_TRACE2("map 1 [ 1 ]",
TypeError, TypeError,
hintfmt("value is %s while a function was expected", "an integer"), hintfmt("expected a function but found %s: %s", "an integer", ANSI_CYAN "1" ANSI_NORMAL),
hintfmt("while evaluating the first argument passed to builtins.map")); hintfmt("while evaluating the first argument passed to builtins.map"));
} }
@ -679,17 +679,17 @@ namespace nix {
TEST_F(ErrorTraceTest, filter) { TEST_F(ErrorTraceTest, filter) {
ASSERT_TRACE2("filter 1 \"foo\"", ASSERT_TRACE2("filter 1 \"foo\"",
TypeError, TypeError,
hintfmt("value is %s while a list was expected", "a string"), hintfmt("expected a list but found %s: %s", "a string", ANSI_MAGENTA "\"foo\"" ANSI_NORMAL),
hintfmt("while evaluating the second argument passed to builtins.filter")); hintfmt("while evaluating the second argument passed to builtins.filter"));
ASSERT_TRACE2("filter 1 [ \"foo\" ]", ASSERT_TRACE2("filter 1 [ \"foo\" ]",
TypeError, TypeError,
hintfmt("value is %s while a function was expected", "an integer"), hintfmt("expected a function but found %s: %s", "an integer", ANSI_CYAN "1" ANSI_NORMAL),
hintfmt("while evaluating the first argument passed to builtins.filter")); hintfmt("while evaluating the first argument passed to builtins.filter"));
ASSERT_TRACE2("filter (_: 5) [ \"foo\" ]", ASSERT_TRACE2("filter (_: 5) [ \"foo\" ]",
TypeError, TypeError,
hintfmt("value is %s while a Boolean was expected", "an integer"), hintfmt("expected a Boolean but found %s: %s", "an integer", ANSI_CYAN "5" ANSI_NORMAL),
hintfmt("while evaluating the return value of the filtering function passed to builtins.filter")); hintfmt("while evaluating the return value of the filtering function passed to builtins.filter"));
} }
@ -698,7 +698,7 @@ namespace nix {
TEST_F(ErrorTraceTest, elem) { TEST_F(ErrorTraceTest, elem) {
ASSERT_TRACE2("elem 1 \"foo\"", ASSERT_TRACE2("elem 1 \"foo\"",
TypeError, TypeError,
hintfmt("value is %s while a list was expected", "a string"), hintfmt("expected a list but found %s: %s", "a string", ANSI_MAGENTA "\"foo\"" ANSI_NORMAL),
hintfmt("while evaluating the second argument passed to builtins.elem")); hintfmt("while evaluating the second argument passed to builtins.elem"));
} }
@ -707,17 +707,17 @@ namespace nix {
TEST_F(ErrorTraceTest, concatLists) { TEST_F(ErrorTraceTest, concatLists) {
ASSERT_TRACE2("concatLists 1", ASSERT_TRACE2("concatLists 1",
TypeError, TypeError,
hintfmt("value is %s while a list was expected", "an integer"), hintfmt("expected a list but found %s: %s", "an integer", ANSI_CYAN "1" ANSI_NORMAL),
hintfmt("while evaluating the first argument passed to builtins.concatLists")); hintfmt("while evaluating the first argument passed to builtins.concatLists"));
ASSERT_TRACE2("concatLists [ 1 ]", ASSERT_TRACE2("concatLists [ 1 ]",
TypeError, TypeError,
hintfmt("value is %s while a list was expected", "an integer"), hintfmt("expected a list but found %s: %s", "an integer", ANSI_CYAN "1" ANSI_NORMAL),
hintfmt("while evaluating a value of the list passed to builtins.concatLists")); hintfmt("while evaluating a value of the list passed to builtins.concatLists"));
ASSERT_TRACE2("concatLists [ [1] \"foo\" ]", ASSERT_TRACE2("concatLists [ [1] \"foo\" ]",
TypeError, TypeError,
hintfmt("value is %s while a list was expected", "a string"), hintfmt("expected a list but found %s: %s", "a string", ANSI_MAGENTA "\"foo\"" ANSI_NORMAL),
hintfmt("while evaluating a value of the list passed to builtins.concatLists")); hintfmt("while evaluating a value of the list passed to builtins.concatLists"));
} }
@ -726,12 +726,12 @@ namespace nix {
TEST_F(ErrorTraceTest, length) { TEST_F(ErrorTraceTest, length) {
ASSERT_TRACE2("length 1", ASSERT_TRACE2("length 1",
TypeError, TypeError,
hintfmt("value is %s while a list was expected", "an integer"), hintfmt("expected a list but found %s: %s", "an integer", ANSI_CYAN "1" ANSI_NORMAL),
hintfmt("while evaluating the first argument passed to builtins.length")); hintfmt("while evaluating the first argument passed to builtins.length"));
ASSERT_TRACE2("length \"foo\"", ASSERT_TRACE2("length \"foo\"",
TypeError, TypeError,
hintfmt("value is %s while a list was expected", "a string"), hintfmt("expected a list but found %s: %s", "a string", ANSI_MAGENTA "\"foo\"" ANSI_NORMAL),
hintfmt("while evaluating the first argument passed to builtins.length")); hintfmt("while evaluating the first argument passed to builtins.length"));
} }
@ -740,12 +740,12 @@ namespace nix {
TEST_F(ErrorTraceTest, foldlPrime) { TEST_F(ErrorTraceTest, foldlPrime) {
ASSERT_TRACE2("foldl' 1 \"foo\" true", ASSERT_TRACE2("foldl' 1 \"foo\" true",
TypeError, TypeError,
hintfmt("value is %s while a function was expected", "an integer"), hintfmt("expected a function but found %s: %s", "an integer", ANSI_CYAN "1" ANSI_NORMAL),
hintfmt("while evaluating the first argument passed to builtins.foldlStrict")); hintfmt("while evaluating the first argument passed to builtins.foldlStrict"));
ASSERT_TRACE2("foldl' (_: 1) \"foo\" true", ASSERT_TRACE2("foldl' (_: 1) \"foo\" true",
TypeError, TypeError,
hintfmt("value is %s while a list was expected", "a Boolean"), hintfmt("expected a list but found %s: %s", "a Boolean", ANSI_CYAN "true" ANSI_NORMAL),
hintfmt("while evaluating the third argument passed to builtins.foldlStrict")); hintfmt("while evaluating the third argument passed to builtins.foldlStrict"));
ASSERT_TRACE1("foldl' (_: 1) \"foo\" [ true ]", ASSERT_TRACE1("foldl' (_: 1) \"foo\" [ true ]",
@ -754,7 +754,7 @@ namespace nix {
ASSERT_TRACE2("foldl' (a: b: a && b) \"foo\" [ true ]", ASSERT_TRACE2("foldl' (a: b: a && b) \"foo\" [ true ]",
TypeError, TypeError,
hintfmt("value is %s while a Boolean was expected", "a string"), hintfmt("expected a Boolean but found %s: %s", "a string", ANSI_MAGENTA "\"foo\"" ANSI_NORMAL),
hintfmt("in the left operand of the AND (&&) operator")); hintfmt("in the left operand of the AND (&&) operator"));
} }
@ -763,17 +763,17 @@ namespace nix {
TEST_F(ErrorTraceTest, any) { TEST_F(ErrorTraceTest, any) {
ASSERT_TRACE2("any 1 \"foo\"", ASSERT_TRACE2("any 1 \"foo\"",
TypeError, TypeError,
hintfmt("value is %s while a function was expected", "an integer"), hintfmt("expected a function but found %s: %s", "an integer", ANSI_CYAN "1" ANSI_NORMAL),
hintfmt("while evaluating the first argument passed to builtins.any")); hintfmt("while evaluating the first argument passed to builtins.any"));
ASSERT_TRACE2("any (_: 1) \"foo\"", ASSERT_TRACE2("any (_: 1) \"foo\"",
TypeError, TypeError,
hintfmt("value is %s while a list was expected", "a string"), hintfmt("expected a list but found %s: %s", "a string", ANSI_MAGENTA "\"foo\"" ANSI_NORMAL),
hintfmt("while evaluating the second argument passed to builtins.any")); hintfmt("while evaluating the second argument passed to builtins.any"));
ASSERT_TRACE2("any (_: 1) [ \"foo\" ]", ASSERT_TRACE2("any (_: 1) [ \"foo\" ]",
TypeError, TypeError,
hintfmt("value is %s while a Boolean was expected", "an integer"), hintfmt("expected a Boolean but found %s: %s", "an integer", ANSI_CYAN "1" ANSI_NORMAL),
hintfmt("while evaluating the return value of the function passed to builtins.any")); hintfmt("while evaluating the return value of the function passed to builtins.any"));
} }
@ -782,17 +782,17 @@ namespace nix {
TEST_F(ErrorTraceTest, all) { TEST_F(ErrorTraceTest, all) {
ASSERT_TRACE2("all 1 \"foo\"", ASSERT_TRACE2("all 1 \"foo\"",
TypeError, TypeError,
hintfmt("value is %s while a function was expected", "an integer"), hintfmt("expected a function but found %s: %s", "an integer", ANSI_CYAN "1" ANSI_NORMAL),
hintfmt("while evaluating the first argument passed to builtins.all")); hintfmt("while evaluating the first argument passed to builtins.all"));
ASSERT_TRACE2("all (_: 1) \"foo\"", ASSERT_TRACE2("all (_: 1) \"foo\"",
TypeError, TypeError,
hintfmt("value is %s while a list was expected", "a string"), hintfmt("expected a list but found %s: %s", "a string", ANSI_MAGENTA "\"foo\"" ANSI_NORMAL),
hintfmt("while evaluating the second argument passed to builtins.all")); hintfmt("while evaluating the second argument passed to builtins.all"));
ASSERT_TRACE2("all (_: 1) [ \"foo\" ]", ASSERT_TRACE2("all (_: 1) [ \"foo\" ]",
TypeError, TypeError,
hintfmt("value is %s while a Boolean was expected", "an integer"), hintfmt("expected a Boolean but found %s: %s", "an integer", ANSI_CYAN "1" ANSI_NORMAL),
hintfmt("while evaluating the return value of the function passed to builtins.all")); hintfmt("while evaluating the return value of the function passed to builtins.all"));
} }
@ -801,12 +801,12 @@ namespace nix {
TEST_F(ErrorTraceTest, genList) { TEST_F(ErrorTraceTest, genList) {
ASSERT_TRACE2("genList 1 \"foo\"", ASSERT_TRACE2("genList 1 \"foo\"",
TypeError, TypeError,
hintfmt("value is %s while an integer was expected", "a string"), hintfmt("expected an integer but found %s: %s", "a string", ANSI_MAGENTA "\"foo\"" ANSI_NORMAL),
hintfmt("while evaluating the second argument passed to builtins.genList")); hintfmt("while evaluating the second argument passed to builtins.genList"));
ASSERT_TRACE2("genList 1 2", ASSERT_TRACE2("genList 1 2",
TypeError, TypeError,
hintfmt("value is %s while a function was expected", "an integer"), hintfmt("expected a function but found %s: %s", "an integer", ANSI_CYAN "1" ANSI_NORMAL),
hintfmt("while evaluating the first argument passed to builtins.genList", "an integer")); hintfmt("while evaluating the first argument passed to builtins.genList", "an integer"));
// XXX: defered // XXX: defered
@ -825,12 +825,12 @@ namespace nix {
TEST_F(ErrorTraceTest, sort) { TEST_F(ErrorTraceTest, sort) {
ASSERT_TRACE2("sort 1 \"foo\"", ASSERT_TRACE2("sort 1 \"foo\"",
TypeError, TypeError,
hintfmt("value is %s while a list was expected", "a string"), hintfmt("expected a list but found %s: %s", "a string", ANSI_MAGENTA "\"foo\"" ANSI_NORMAL),
hintfmt("while evaluating the second argument passed to builtins.sort")); hintfmt("while evaluating the second argument passed to builtins.sort"));
ASSERT_TRACE2("sort 1 [ \"foo\" ]", ASSERT_TRACE2("sort 1 [ \"foo\" ]",
TypeError, TypeError,
hintfmt("value is %s while a function was expected", "an integer"), hintfmt("expected a function but found %s: %s", "an integer", ANSI_CYAN "1" ANSI_NORMAL),
hintfmt("while evaluating the first argument passed to builtins.sort")); hintfmt("while evaluating the first argument passed to builtins.sort"));
ASSERT_TRACE1("sort (_: 1) [ \"foo\" \"bar\" ]", ASSERT_TRACE1("sort (_: 1) [ \"foo\" \"bar\" ]",
@ -839,7 +839,7 @@ namespace nix {
ASSERT_TRACE2("sort (_: _: 1) [ \"foo\" \"bar\" ]", ASSERT_TRACE2("sort (_: _: 1) [ \"foo\" \"bar\" ]",
TypeError, TypeError,
hintfmt("value is %s while a Boolean was expected", "an integer"), hintfmt("expected a Boolean but found %s: %s", "an integer", ANSI_CYAN "1" ANSI_NORMAL),
hintfmt("while evaluating the return value of the sorting function passed to builtins.sort")); hintfmt("while evaluating the return value of the sorting function passed to builtins.sort"));
// XXX: Trace too deep, need better asserts // XXX: Trace too deep, need better asserts
@ -857,17 +857,17 @@ namespace nix {
TEST_F(ErrorTraceTest, partition) { TEST_F(ErrorTraceTest, partition) {
ASSERT_TRACE2("partition 1 \"foo\"", ASSERT_TRACE2("partition 1 \"foo\"",
TypeError, TypeError,
hintfmt("value is %s while a function was expected", "an integer"), hintfmt("expected a function but found %s: %s", "an integer", ANSI_CYAN "1" ANSI_NORMAL),
hintfmt("while evaluating the first argument passed to builtins.partition")); hintfmt("while evaluating the first argument passed to builtins.partition"));
ASSERT_TRACE2("partition (_: 1) \"foo\"", ASSERT_TRACE2("partition (_: 1) \"foo\"",
TypeError, TypeError,
hintfmt("value is %s while a list was expected", "a string"), hintfmt("expected a list but found %s: %s", "a string", ANSI_MAGENTA "\"foo\"" ANSI_NORMAL),
hintfmt("while evaluating the second argument passed to builtins.partition")); hintfmt("while evaluating the second argument passed to builtins.partition"));
ASSERT_TRACE2("partition (_: 1) [ \"foo\" ]", ASSERT_TRACE2("partition (_: 1) [ \"foo\" ]",
TypeError, TypeError,
hintfmt("value is %s while a Boolean was expected", "an integer"), hintfmt("expected a Boolean but found %s: %s", "an integer", ANSI_CYAN "1" ANSI_NORMAL),
hintfmt("while evaluating the return value of the partition function passed to builtins.partition")); hintfmt("while evaluating the return value of the partition function passed to builtins.partition"));
} }
@ -876,17 +876,17 @@ namespace nix {
TEST_F(ErrorTraceTest, groupBy) { TEST_F(ErrorTraceTest, groupBy) {
ASSERT_TRACE2("groupBy 1 \"foo\"", ASSERT_TRACE2("groupBy 1 \"foo\"",
TypeError, TypeError,
hintfmt("value is %s while a function was expected", "an integer"), hintfmt("expected a function but found %s: %s", "an integer", ANSI_CYAN "1" ANSI_NORMAL),
hintfmt("while evaluating the first argument passed to builtins.groupBy")); hintfmt("while evaluating the first argument passed to builtins.groupBy"));
ASSERT_TRACE2("groupBy (_: 1) \"foo\"", ASSERT_TRACE2("groupBy (_: 1) \"foo\"",
TypeError, TypeError,
hintfmt("value is %s while a list was expected", "a string"), hintfmt("expected a list but found %s: %s", "a string", ANSI_MAGENTA "\"foo\"" ANSI_NORMAL),
hintfmt("while evaluating the second argument passed to builtins.groupBy")); hintfmt("while evaluating the second argument passed to builtins.groupBy"));
ASSERT_TRACE2("groupBy (x: x) [ \"foo\" \"bar\" 1 ]", ASSERT_TRACE2("groupBy (x: x) [ \"foo\" \"bar\" 1 ]",
TypeError, TypeError,
hintfmt("value is %s while a string was expected", "an integer"), hintfmt("expected a string but found %s: %s", "an integer", ANSI_CYAN "1" ANSI_NORMAL),
hintfmt("while evaluating the return value of the grouping function passed to builtins.groupBy")); hintfmt("while evaluating the return value of the grouping function passed to builtins.groupBy"));
} }
@ -895,22 +895,22 @@ namespace nix {
TEST_F(ErrorTraceTest, concatMap) { TEST_F(ErrorTraceTest, concatMap) {
ASSERT_TRACE2("concatMap 1 \"foo\"", ASSERT_TRACE2("concatMap 1 \"foo\"",
TypeError, TypeError,
hintfmt("value is %s while a function was expected", "an integer"), hintfmt("expected a function but found %s: %s", "an integer", ANSI_CYAN "1" ANSI_NORMAL),
hintfmt("while evaluating the first argument passed to builtins.concatMap")); hintfmt("while evaluating the first argument passed to builtins.concatMap"));
ASSERT_TRACE2("concatMap (x: 1) \"foo\"", ASSERT_TRACE2("concatMap (x: 1) \"foo\"",
TypeError, TypeError,
hintfmt("value is %s while a list was expected", "a string"), hintfmt("expected a list but found %s: %s", "a string", ANSI_MAGENTA "\"foo\"" ANSI_NORMAL),
hintfmt("while evaluating the second argument passed to builtins.concatMap")); hintfmt("while evaluating the second argument passed to builtins.concatMap"));
ASSERT_TRACE2("concatMap (x: 1) [ \"foo\" ] # TODO", ASSERT_TRACE2("concatMap (x: 1) [ \"foo\" ] # TODO",
TypeError, TypeError,
hintfmt("value is %s while a list was expected", "an integer"), hintfmt("expected a list but found %s: %s", "an integer", ANSI_CYAN "1" ANSI_NORMAL),
hintfmt("while evaluating the return value of the function passed to builtins.concatMap")); hintfmt("while evaluating the return value of the function passed to builtins.concatMap"));
ASSERT_TRACE2("concatMap (x: \"foo\") [ 1 2 ] # TODO", ASSERT_TRACE2("concatMap (x: \"foo\") [ 1 2 ] # TODO",
TypeError, TypeError,
hintfmt("value is %s while a list was expected", "a string"), hintfmt("expected a list but found %s: %s", "a string", ANSI_MAGENTA "\"foo\"" ANSI_NORMAL),
hintfmt("while evaluating the return value of the function passed to builtins.concatMap")); hintfmt("while evaluating the return value of the function passed to builtins.concatMap"));
} }
@ -919,12 +919,12 @@ namespace nix {
TEST_F(ErrorTraceTest, add) { TEST_F(ErrorTraceTest, add) {
ASSERT_TRACE2("add \"foo\" 1", ASSERT_TRACE2("add \"foo\" 1",
TypeError, TypeError,
hintfmt("value is %s while an integer was expected", "a string"), hintfmt("expected an integer but found %s: %s", "a string", ANSI_MAGENTA "\"foo\"" ANSI_NORMAL),
hintfmt("while evaluating the first argument of the addition")); hintfmt("while evaluating the first argument of the addition"));
ASSERT_TRACE2("add 1 \"foo\"", ASSERT_TRACE2("add 1 \"foo\"",
TypeError, TypeError,
hintfmt("value is %s while an integer was expected", "a string"), hintfmt("expected an integer but found %s: %s", "a string", ANSI_MAGENTA "\"foo\"" ANSI_NORMAL),
hintfmt("while evaluating the second argument of the addition")); hintfmt("while evaluating the second argument of the addition"));
} }
@ -933,12 +933,12 @@ namespace nix {
TEST_F(ErrorTraceTest, sub) { TEST_F(ErrorTraceTest, sub) {
ASSERT_TRACE2("sub \"foo\" 1", ASSERT_TRACE2("sub \"foo\" 1",
TypeError, TypeError,
hintfmt("value is %s while an integer was expected", "a string"), hintfmt("expected an integer but found %s: %s", "a string", ANSI_MAGENTA "\"foo\"" ANSI_NORMAL),
hintfmt("while evaluating the first argument of the subtraction")); hintfmt("while evaluating the first argument of the subtraction"));
ASSERT_TRACE2("sub 1 \"foo\"", ASSERT_TRACE2("sub 1 \"foo\"",
TypeError, TypeError,
hintfmt("value is %s while an integer was expected", "a string"), hintfmt("expected an integer but found %s: %s", "a string", ANSI_MAGENTA "\"foo\"" ANSI_NORMAL),
hintfmt("while evaluating the second argument of the subtraction")); hintfmt("while evaluating the second argument of the subtraction"));
} }
@ -947,12 +947,12 @@ namespace nix {
TEST_F(ErrorTraceTest, mul) { TEST_F(ErrorTraceTest, mul) {
ASSERT_TRACE2("mul \"foo\" 1", ASSERT_TRACE2("mul \"foo\" 1",
TypeError, TypeError,
hintfmt("value is %s while an integer was expected", "a string"), hintfmt("expected an integer but found %s: %s", "a string", ANSI_MAGENTA "\"foo\"" ANSI_NORMAL),
hintfmt("while evaluating the first argument of the multiplication")); hintfmt("while evaluating the first argument of the multiplication"));
ASSERT_TRACE2("mul 1 \"foo\"", ASSERT_TRACE2("mul 1 \"foo\"",
TypeError, TypeError,
hintfmt("value is %s while an integer was expected", "a string"), hintfmt("expected an integer but found %s: %s", "a string", ANSI_MAGENTA "\"foo\"" ANSI_NORMAL),
hintfmt("while evaluating the second argument of the multiplication")); hintfmt("while evaluating the second argument of the multiplication"));
} }
@ -961,12 +961,12 @@ namespace nix {
TEST_F(ErrorTraceTest, div) { TEST_F(ErrorTraceTest, div) {
ASSERT_TRACE2("div \"foo\" 1 # TODO: an integer was expected -> a number", ASSERT_TRACE2("div \"foo\" 1 # TODO: an integer was expected -> a number",
TypeError, TypeError,
hintfmt("value is %s while an integer was expected", "a string"), hintfmt("expected an integer but found %s: %s", "a string", ANSI_MAGENTA "\"foo\"" ANSI_NORMAL),
hintfmt("while evaluating the first operand of the division")); hintfmt("while evaluating the first operand of the division"));
ASSERT_TRACE2("div 1 \"foo\"", ASSERT_TRACE2("div 1 \"foo\"",
TypeError, TypeError,
hintfmt("value is %s while a float was expected", "a string"), hintfmt("expected a float but found %s: %s", "a string", ANSI_MAGENTA "\"foo\"" ANSI_NORMAL),
hintfmt("while evaluating the second operand of the division")); hintfmt("while evaluating the second operand of the division"));
ASSERT_TRACE1("div \"foo\" 0", ASSERT_TRACE1("div \"foo\" 0",
@ -979,12 +979,12 @@ namespace nix {
TEST_F(ErrorTraceTest, bitAnd) { TEST_F(ErrorTraceTest, bitAnd) {
ASSERT_TRACE2("bitAnd 1.1 2", ASSERT_TRACE2("bitAnd 1.1 2",
TypeError, TypeError,
hintfmt("value is %s while an integer was expected", "a float"), hintfmt("expected an integer but found %s: %s", "a float", ANSI_CYAN "1.1" ANSI_NORMAL),
hintfmt("while evaluating the first argument passed to builtins.bitAnd")); hintfmt("while evaluating the first argument passed to builtins.bitAnd"));
ASSERT_TRACE2("bitAnd 1 2.2", ASSERT_TRACE2("bitAnd 1 2.2",
TypeError, TypeError,
hintfmt("value is %s while an integer was expected", "a float"), hintfmt("expected an integer but found %s: %s", "a float", ANSI_CYAN "2.2" ANSI_NORMAL),
hintfmt("while evaluating the second argument passed to builtins.bitAnd")); hintfmt("while evaluating the second argument passed to builtins.bitAnd"));
} }
@ -993,12 +993,12 @@ namespace nix {
TEST_F(ErrorTraceTest, bitOr) { TEST_F(ErrorTraceTest, bitOr) {
ASSERT_TRACE2("bitOr 1.1 2", ASSERT_TRACE2("bitOr 1.1 2",
TypeError, TypeError,
hintfmt("value is %s while an integer was expected", "a float"), hintfmt("expected an integer but found %s: %s", "a float", ANSI_CYAN "1.1" ANSI_NORMAL),
hintfmt("while evaluating the first argument passed to builtins.bitOr")); hintfmt("while evaluating the first argument passed to builtins.bitOr"));
ASSERT_TRACE2("bitOr 1 2.2", ASSERT_TRACE2("bitOr 1 2.2",
TypeError, TypeError,
hintfmt("value is %s while an integer was expected", "a float"), hintfmt("expected an integer but found %s: %s", "a float", ANSI_CYAN "2.2" ANSI_NORMAL),
hintfmt("while evaluating the second argument passed to builtins.bitOr")); hintfmt("while evaluating the second argument passed to builtins.bitOr"));
} }
@ -1007,12 +1007,12 @@ namespace nix {
TEST_F(ErrorTraceTest, bitXor) { TEST_F(ErrorTraceTest, bitXor) {
ASSERT_TRACE2("bitXor 1.1 2", ASSERT_TRACE2("bitXor 1.1 2",
TypeError, TypeError,
hintfmt("value is %s while an integer was expected", "a float"), hintfmt("expected an integer but found %s: %s", "a float", ANSI_CYAN "1.1" ANSI_NORMAL),
hintfmt("while evaluating the first argument passed to builtins.bitXor")); hintfmt("while evaluating the first argument passed to builtins.bitXor"));
ASSERT_TRACE2("bitXor 1 2.2", ASSERT_TRACE2("bitXor 1 2.2",
TypeError, TypeError,
hintfmt("value is %s while an integer was expected", "a float"), hintfmt("expected an integer but found %s: %s", "a float", ANSI_CYAN "2.2" ANSI_NORMAL),
hintfmt("while evaluating the second argument passed to builtins.bitXor")); hintfmt("while evaluating the second argument passed to builtins.bitXor"));
} }
@ -1047,12 +1047,12 @@ namespace nix {
TEST_F(ErrorTraceTest, substring) { TEST_F(ErrorTraceTest, substring) {
ASSERT_TRACE2("substring {} \"foo\" true", ASSERT_TRACE2("substring {} \"foo\" true",
TypeError, TypeError,
hintfmt("value is %s while an integer was expected", "a set"), hintfmt("expected an integer but found %s: %s", "a set", "{ }"),
hintfmt("while evaluating the first argument (the start offset) passed to builtins.substring")); hintfmt("while evaluating the first argument (the start offset) passed to builtins.substring"));
ASSERT_TRACE2("substring 3 \"foo\" true", ASSERT_TRACE2("substring 3 \"foo\" true",
TypeError, TypeError,
hintfmt("value is %s while an integer was expected", "a string"), hintfmt("expected an integer but found %s: %s", "a string", ANSI_MAGENTA "\"foo\"" ANSI_NORMAL),
hintfmt("while evaluating the second argument (the substring length) passed to builtins.substring")); hintfmt("while evaluating the second argument (the substring length) passed to builtins.substring"));
ASSERT_TRACE2("substring 0 3 {}", ASSERT_TRACE2("substring 0 3 {}",
@ -1079,7 +1079,7 @@ namespace nix {
TEST_F(ErrorTraceTest, hashString) { TEST_F(ErrorTraceTest, hashString) {
ASSERT_TRACE2("hashString 1 {}", ASSERT_TRACE2("hashString 1 {}",
TypeError, TypeError,
hintfmt("value is %s while a string was expected", "an integer"), hintfmt("expected a string but found %s: %s", "an integer", ANSI_CYAN "1" ANSI_NORMAL),
hintfmt("while evaluating the first argument passed to builtins.hashString")); hintfmt("while evaluating the first argument passed to builtins.hashString"));
ASSERT_TRACE1("hashString \"foo\" \"content\"", ASSERT_TRACE1("hashString \"foo\" \"content\"",
@ -1088,7 +1088,7 @@ namespace nix {
ASSERT_TRACE2("hashString \"sha256\" {}", ASSERT_TRACE2("hashString \"sha256\" {}",
TypeError, TypeError,
hintfmt("value is %s while a string was expected", "a set"), hintfmt("expected a string but found %s: %s", "a set", "{ }"),
hintfmt("while evaluating the second argument passed to builtins.hashString")); hintfmt("while evaluating the second argument passed to builtins.hashString"));
} }
@ -1097,12 +1097,12 @@ namespace nix {
TEST_F(ErrorTraceTest, match) { TEST_F(ErrorTraceTest, match) {
ASSERT_TRACE2("match 1 {}", ASSERT_TRACE2("match 1 {}",
TypeError, TypeError,
hintfmt("value is %s while a string was expected", "an integer"), hintfmt("expected a string but found %s: %s", "an integer", ANSI_CYAN "1" ANSI_NORMAL),
hintfmt("while evaluating the first argument passed to builtins.match")); hintfmt("while evaluating the first argument passed to builtins.match"));
ASSERT_TRACE2("match \"foo\" {}", ASSERT_TRACE2("match \"foo\" {}",
TypeError, TypeError,
hintfmt("value is %s while a string was expected", "a set"), hintfmt("expected a string but found %s: %s", "a set", "{ }"),
hintfmt("while evaluating the second argument passed to builtins.match")); hintfmt("while evaluating the second argument passed to builtins.match"));
ASSERT_TRACE1("match \"(.*\" \"\"", ASSERT_TRACE1("match \"(.*\" \"\"",
@ -1115,12 +1115,12 @@ namespace nix {
TEST_F(ErrorTraceTest, split) { TEST_F(ErrorTraceTest, split) {
ASSERT_TRACE2("split 1 {}", ASSERT_TRACE2("split 1 {}",
TypeError, TypeError,
hintfmt("value is %s while a string was expected", "an integer"), hintfmt("expected a string but found %s: %s", "an integer", ANSI_CYAN "1" ANSI_NORMAL),
hintfmt("while evaluating the first argument passed to builtins.split")); hintfmt("while evaluating the first argument passed to builtins.split"));
ASSERT_TRACE2("split \"foo\" {}", ASSERT_TRACE2("split \"foo\" {}",
TypeError, TypeError,
hintfmt("value is %s while a string was expected", "a set"), hintfmt("expected a string but found %s: %s", "a set", "{ }"),
hintfmt("while evaluating the second argument passed to builtins.split")); hintfmt("while evaluating the second argument passed to builtins.split"));
ASSERT_TRACE1("split \"f(o*o\" \"1foo2\"", ASSERT_TRACE1("split \"f(o*o\" \"1foo2\"",
@ -1133,12 +1133,12 @@ namespace nix {
TEST_F(ErrorTraceTest, concatStringsSep) { TEST_F(ErrorTraceTest, concatStringsSep) {
ASSERT_TRACE2("concatStringsSep 1 {}", ASSERT_TRACE2("concatStringsSep 1 {}",
TypeError, TypeError,
hintfmt("value is %s while a string was expected", "an integer"), hintfmt("expected a string but found %s: %s", "an integer", ANSI_CYAN "1" ANSI_NORMAL),
hintfmt("while evaluating the first argument (the separator string) passed to builtins.concatStringsSep")); hintfmt("while evaluating the first argument (the separator string) passed to builtins.concatStringsSep"));
ASSERT_TRACE2("concatStringsSep \"foo\" {}", ASSERT_TRACE2("concatStringsSep \"foo\" {}",
TypeError, TypeError,
hintfmt("value is %s while a list was expected", "a set"), hintfmt("expected a list but found %s: %s", "a set", "{ }"),
hintfmt("while evaluating the second argument (the list of strings to concat) passed to builtins.concatStringsSep")); hintfmt("while evaluating the second argument (the list of strings to concat) passed to builtins.concatStringsSep"));
ASSERT_TRACE2("concatStringsSep \"foo\" [ 1 2 {} ] # TODO: coerce to string is buggy", ASSERT_TRACE2("concatStringsSep \"foo\" [ 1 2 {} ] # TODO: coerce to string is buggy",
@ -1152,7 +1152,7 @@ namespace nix {
TEST_F(ErrorTraceTest, parseDrvName) { TEST_F(ErrorTraceTest, parseDrvName) {
ASSERT_TRACE2("parseDrvName 1", ASSERT_TRACE2("parseDrvName 1",
TypeError, TypeError,
hintfmt("value is %s while a string was expected", "an integer"), hintfmt("expected a string but found %s: %s", "an integer", ANSI_CYAN "1" ANSI_NORMAL),
hintfmt("while evaluating the first argument passed to builtins.parseDrvName")); hintfmt("while evaluating the first argument passed to builtins.parseDrvName"));
} }
@ -1161,12 +1161,12 @@ namespace nix {
TEST_F(ErrorTraceTest, compareVersions) { TEST_F(ErrorTraceTest, compareVersions) {
ASSERT_TRACE2("compareVersions 1 {}", ASSERT_TRACE2("compareVersions 1 {}",
TypeError, TypeError,
hintfmt("value is %s while a string was expected", "an integer"), hintfmt("expected a string but found %s: %s", "an integer", ANSI_CYAN "1" ANSI_NORMAL),
hintfmt("while evaluating the first argument passed to builtins.compareVersions")); hintfmt("while evaluating the first argument passed to builtins.compareVersions"));
ASSERT_TRACE2("compareVersions \"abd\" {}", ASSERT_TRACE2("compareVersions \"abd\" {}",
TypeError, TypeError,
hintfmt("value is %s while a string was expected", "a set"), hintfmt("expected a string but found %s: %s", "a set", "{ }"),
hintfmt("while evaluating the second argument passed to builtins.compareVersions")); hintfmt("while evaluating the second argument passed to builtins.compareVersions"));
} }
@ -1175,7 +1175,7 @@ namespace nix {
TEST_F(ErrorTraceTest, splitVersion) { TEST_F(ErrorTraceTest, splitVersion) {
ASSERT_TRACE2("splitVersion 1", ASSERT_TRACE2("splitVersion 1",
TypeError, TypeError,
hintfmt("value is %s while a string was expected", "an integer"), hintfmt("expected a string but found %s: %s", "an integer", ANSI_CYAN "1" ANSI_NORMAL),
hintfmt("while evaluating the first argument passed to builtins.splitVersion")); hintfmt("while evaluating the first argument passed to builtins.splitVersion"));
} }
@ -1189,7 +1189,7 @@ namespace nix {
TEST_F(ErrorTraceTest, derivationStrict) { TEST_F(ErrorTraceTest, derivationStrict) {
ASSERT_TRACE2("derivationStrict \"\"", ASSERT_TRACE2("derivationStrict \"\"",
TypeError, TypeError,
hintfmt("value is %s while a set was expected", "a string"), hintfmt("expected a set but found %s: %s", "a string", "\"\""),
hintfmt("while evaluating the argument passed to builtins.derivationStrict")); hintfmt("while evaluating the argument passed to builtins.derivationStrict"));
ASSERT_TRACE2("derivationStrict {}", ASSERT_TRACE2("derivationStrict {}",
@ -1199,7 +1199,7 @@ namespace nix {
ASSERT_TRACE2("derivationStrict { name = 1; }", ASSERT_TRACE2("derivationStrict { name = 1; }",
TypeError, TypeError,
hintfmt("value is %s while a string was expected", "an integer"), hintfmt("expected a string but found %s: %s", "an integer", "1"),
hintfmt("while evaluating the `name` attribute passed to builtins.derivationStrict")); hintfmt("while evaluating the `name` attribute passed to builtins.derivationStrict"));
ASSERT_TRACE2("derivationStrict { name = \"foo\"; }", ASSERT_TRACE2("derivationStrict { name = \"foo\"; }",
@ -1209,12 +1209,12 @@ namespace nix {
ASSERT_TRACE2("derivationStrict { name = \"foo\"; builder = 1; __structuredAttrs = 15; }", ASSERT_TRACE2("derivationStrict { name = \"foo\"; builder = 1; __structuredAttrs = 15; }",
TypeError, TypeError,
hintfmt("value is %s while a Boolean was expected", "an integer"), hintfmt("expected a Boolean but found %s: %s", "an integer", "15"),
hintfmt("while evaluating the `__structuredAttrs` attribute passed to builtins.derivationStrict")); hintfmt("while evaluating the `__structuredAttrs` attribute passed to builtins.derivationStrict"));
ASSERT_TRACE2("derivationStrict { name = \"foo\"; builder = 1; __ignoreNulls = 15; }", ASSERT_TRACE2("derivationStrict { name = \"foo\"; builder = 1; __ignoreNulls = 15; }",
TypeError, TypeError,
hintfmt("value is %s while a Boolean was expected", "an integer"), hintfmt("expected a Boolean but found %s: %s", "an integer", "15"),
hintfmt("while evaluating the `__ignoreNulls` attribute passed to builtins.derivationStrict")); hintfmt("while evaluating the `__ignoreNulls` attribute passed to builtins.derivationStrict"));
ASSERT_TRACE2("derivationStrict { name = \"foo\"; builder = 1; outputHashMode = 15; }", ASSERT_TRACE2("derivationStrict { name = \"foo\"; builder = 1; outputHashMode = 15; }",
@ -1259,22 +1259,22 @@ namespace nix {
ASSERT_TRACE2("derivationStrict { name = \"foo\"; builder = 1; system = 1; outputs = \"out\"; __contentAddressed = \"true\"; }", ASSERT_TRACE2("derivationStrict { name = \"foo\"; builder = 1; system = 1; outputs = \"out\"; __contentAddressed = \"true\"; }",
TypeError, TypeError,
hintfmt("value is %s while a Boolean was expected", "a string"), hintfmt("expected a Boolean but found %s: %s", "a string", "\"true\""),
hintfmt("while evaluating the attribute '__contentAddressed' of derivation 'foo'")); hintfmt("while evaluating the attribute '__contentAddressed' of derivation 'foo'"));
ASSERT_TRACE2("derivationStrict { name = \"foo\"; builder = 1; system = 1; outputs = \"out\"; __impure = \"true\"; }", ASSERT_TRACE2("derivationStrict { name = \"foo\"; builder = 1; system = 1; outputs = \"out\"; __impure = \"true\"; }",
TypeError, TypeError,
hintfmt("value is %s while a Boolean was expected", "a string"), hintfmt("expected a Boolean but found %s: %s", "a string", "\"true\""),
hintfmt("while evaluating the attribute '__impure' of derivation 'foo'")); hintfmt("while evaluating the attribute '__impure' of derivation 'foo'"));
ASSERT_TRACE2("derivationStrict { name = \"foo\"; builder = 1; system = 1; outputs = \"out\"; __impure = \"true\"; }", ASSERT_TRACE2("derivationStrict { name = \"foo\"; builder = 1; system = 1; outputs = \"out\"; __impure = \"true\"; }",
TypeError, TypeError,
hintfmt("value is %s while a Boolean was expected", "a string"), hintfmt("expected a Boolean but found %s: %s", "a string", "\"true\""),
hintfmt("while evaluating the attribute '__impure' of derivation 'foo'")); hintfmt("while evaluating the attribute '__impure' of derivation 'foo'"));
ASSERT_TRACE2("derivationStrict { name = \"foo\"; builder = 1; system = 1; outputs = \"out\"; args = \"foo\"; }", ASSERT_TRACE2("derivationStrict { name = \"foo\"; builder = 1; system = 1; outputs = \"out\"; args = \"foo\"; }",
TypeError, TypeError,
hintfmt("value is %s while a list was expected", "a string"), hintfmt("expected a list but found %s: %s", "a string", "\"foo\""),
hintfmt("while evaluating the attribute 'args' of derivation 'foo'")); hintfmt("while evaluating the attribute 'args' of derivation 'foo'"));
ASSERT_TRACE2("derivationStrict { name = \"foo\"; builder = 1; system = 1; outputs = \"out\"; args = [ {} ]; }", ASSERT_TRACE2("derivationStrict { name = \"foo\"; builder = 1; system = 1; outputs = \"out\"; args = [ {} ]; }",