1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 23:11:16 +02:00

forceList: Show position info

This commit is contained in:
Eelco Dolstra 2014-04-04 19:05:36 +02:00
parent b62d36963c
commit 96b695ccab
5 changed files with 35 additions and 24 deletions

View file

@ -18,6 +18,12 @@ LocalNoInlineNoReturn(void throwTypeError(const char * s, const Value & v))
}
LocalNoInlineNoReturn(void throwTypeError(const char * s, const Value & v, const Pos & pos))
{
throw TypeError(format(s) % showType(v) % pos);
}
void EvalState::forceValue(Value & v)
{
if (v.type == tThunk) {
@ -56,4 +62,13 @@ inline void EvalState::forceList(Value & v)
throwTypeError("value is %1% while a list was expected", v);
}
inline void EvalState::forceList(Value & v, const Pos & pos)
{
forceValue(v);
if (v.type != tList)
throwTypeError("value is %1% while a list was expected, at %2%", v, pos);
}
}