trying debugThrow
This commit is contained in:
parent
99d69ac23f
commit
2c9fafdc9e
|
@ -556,8 +556,7 @@ std::string AttrCursor::getString()
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
auto e = TypeError("'%s' is not a string", getAttrPathStr());
|
auto e = TypeError("'%s' is not a string", getAttrPathStr());
|
||||||
root->state.debugLastTrace(e);
|
root->state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -567,8 +566,7 @@ std::string AttrCursor::getString()
|
||||||
if (v.type() != nString && v.type() != nPath)
|
if (v.type() != nString && v.type() != nPath)
|
||||||
{
|
{
|
||||||
auto e = TypeError("'%s' is not a string but %s", getAttrPathStr(), showType(v.type()));
|
auto e = TypeError("'%s' is not a string but %s", getAttrPathStr(), showType(v.type()));
|
||||||
root->state.debugLastTrace(e);
|
root->state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return v.type() == nString ? v.string.s : v.path;
|
return v.type() == nString ? v.string.s : v.path;
|
||||||
|
@ -595,8 +593,7 @@ string_t AttrCursor::getStringWithContext()
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
auto e = TypeError("'%s' is not a string", getAttrPathStr());
|
auto e = TypeError("'%s' is not a string", getAttrPathStr());
|
||||||
root->state.debugLastTrace(e);
|
root->state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -610,9 +607,7 @@ string_t AttrCursor::getStringWithContext()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto e = TypeError("'%s' is not a string but %s", getAttrPathStr(), showType(v.type()));
|
auto e = TypeError("'%s' is not a string but %s", getAttrPathStr(), showType(v.type()));
|
||||||
root->state.debugLastTrace(e);
|
root->state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
return {v.path, {}}; // should never execute
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -628,8 +623,7 @@ bool AttrCursor::getBool()
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
auto e = TypeError("'%s' is not a Boolean", getAttrPathStr());
|
auto e = TypeError("'%s' is not a Boolean", getAttrPathStr());
|
||||||
root->state.debugLastTrace(e);
|
root->state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -639,8 +633,7 @@ bool AttrCursor::getBool()
|
||||||
if (v.type() != nBool)
|
if (v.type() != nBool)
|
||||||
{
|
{
|
||||||
auto e = TypeError("'%s' is not a Boolean", getAttrPathStr());
|
auto e = TypeError("'%s' is not a Boolean", getAttrPathStr());
|
||||||
root->state.debugLastTrace(e);
|
root->state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return v.boolean;
|
return v.boolean;
|
||||||
|
@ -691,8 +684,7 @@ std::vector<Symbol> AttrCursor::getAttrs()
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
auto e = TypeError("'%s' is not an attribute set", getAttrPathStr());
|
auto e = TypeError("'%s' is not an attribute set", getAttrPathStr());
|
||||||
root->state.debugLastTrace(e);
|
root->state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -702,8 +694,7 @@ std::vector<Symbol> AttrCursor::getAttrs()
|
||||||
if (v.type() != nAttrs)
|
if (v.type() != nAttrs)
|
||||||
{
|
{
|
||||||
auto e = TypeError("'%s' is not an attribute set", getAttrPathStr());
|
auto e = TypeError("'%s' is not an attribute set", getAttrPathStr());
|
||||||
root->state.debugLastTrace(e);
|
root->state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Symbol> attrs;
|
std::vector<Symbol> attrs;
|
||||||
|
|
|
@ -802,8 +802,9 @@ std::unique_ptr<ValMap> mapStaticEnvBindings(const SymbolTable & st, const Stati
|
||||||
return vm;
|
return vm;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EvalState::debugLastTrace(Error & e) const
|
void EvalState::debugThrowLastTrace(Error & e) const
|
||||||
{
|
{
|
||||||
|
std::cout << "debugThrowLastTrace(Error & e) const" << (debuggerHook == nullptr) << std::endl;
|
||||||
// Call this in the situation where Expr and Env are inaccessible.
|
// Call this in the situation where Expr and Env are inaccessible.
|
||||||
// The debugger will start in the last context that's in the
|
// The debugger will start in the last context that's in the
|
||||||
// DebugTrace stack.
|
// DebugTrace stack.
|
||||||
|
@ -811,6 +812,18 @@ void EvalState::debugLastTrace(Error & e) const
|
||||||
const DebugTrace & last = debugTraces.front();
|
const DebugTrace & last = debugTraces.front();
|
||||||
debuggerHook(&e, last.env, last.expr);
|
debuggerHook(&e, last.env, last.expr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void EvalState::debugThrow(const Error &error, const Env & env, const Expr & expr) const
|
||||||
|
{
|
||||||
|
std::cout << "debugThrow" << (debuggerHook == nullptr) << std::endl;
|
||||||
|
if (debuggerHook)
|
||||||
|
debuggerHook(&error, env, expr);
|
||||||
|
|
||||||
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Every "format" object (even temporary) takes up a few hundred bytes
|
/* Every "format" object (even temporary) takes up a few hundred bytes
|
||||||
|
@ -824,10 +837,7 @@ void EvalState::throwEvalError(const PosIdx pos, const char * s, Env & env, Expr
|
||||||
.errPos = positions[pos]
|
.errPos = positions[pos]
|
||||||
});
|
});
|
||||||
|
|
||||||
if (debuggerHook)
|
debugThrow(error, env, expr);
|
||||||
debuggerHook(&error, env, expr);
|
|
||||||
|
|
||||||
throw error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EvalState::throwEvalError(const PosIdx pos, const char * s) const
|
void EvalState::throwEvalError(const PosIdx pos, const char * s) const
|
||||||
|
@ -837,18 +847,14 @@ void EvalState::throwEvalError(const PosIdx pos, const char * s) const
|
||||||
.errPos = positions[pos]
|
.errPos = positions[pos]
|
||||||
});
|
});
|
||||||
|
|
||||||
debugLastTrace(error);
|
debugThrowLastTrace(error);
|
||||||
|
|
||||||
throw error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EvalState::throwEvalError(const char * s, const std::string & s2) const
|
void EvalState::throwEvalError(const char * s, const std::string & s2) const
|
||||||
{
|
{
|
||||||
auto error = EvalError(s, s2);
|
auto error = EvalError(s, s2);
|
||||||
|
|
||||||
debugLastTrace(error);
|
debugThrowLastTrace(error);
|
||||||
|
|
||||||
throw error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EvalState::throwEvalError(const PosIdx pos, const Suggestions & suggestions, const char * s,
|
void EvalState::throwEvalError(const PosIdx pos, const Suggestions & suggestions, const char * s,
|
||||||
|
@ -860,10 +866,7 @@ void EvalState::throwEvalError(const PosIdx pos, const Suggestions & suggestions
|
||||||
.suggestions = suggestions,
|
.suggestions = suggestions,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (debuggerHook)
|
debugThrow(error, env, expr);
|
||||||
debuggerHook(&error, env, expr);
|
|
||||||
|
|
||||||
throw error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EvalState::throwEvalError(const PosIdx pos, const char * s, const std::string & s2) const
|
void EvalState::throwEvalError(const PosIdx pos, const char * s, const std::string & s2) const
|
||||||
|
@ -873,9 +876,7 @@ void EvalState::throwEvalError(const PosIdx pos, const char * s, const std::stri
|
||||||
.errPos = positions[pos]
|
.errPos = positions[pos]
|
||||||
});
|
});
|
||||||
|
|
||||||
debugLastTrace(error);
|
debugThrowLastTrace(error);
|
||||||
|
|
||||||
throw error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EvalState::throwEvalError(const PosIdx pos, const char * s, const std::string & s2, Env & env, Expr & expr) const
|
void EvalState::throwEvalError(const PosIdx pos, const char * s, const std::string & s2, Env & env, Expr & expr) const
|
||||||
|
@ -885,10 +886,7 @@ void EvalState::throwEvalError(const PosIdx pos, const char * s, const std::stri
|
||||||
.errPos = positions[pos]
|
.errPos = positions[pos]
|
||||||
});
|
});
|
||||||
|
|
||||||
if (debuggerHook)
|
debugThrow(error, env, expr);
|
||||||
debuggerHook(&error, env, expr);
|
|
||||||
|
|
||||||
throw error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EvalState::throwEvalError(const char * s, const std::string & s2,
|
void EvalState::throwEvalError(const char * s, const std::string & s2,
|
||||||
|
@ -899,9 +897,7 @@ void EvalState::throwEvalError(const char * s, const std::string & s2,
|
||||||
.errPos = positions[noPos]
|
.errPos = positions[noPos]
|
||||||
});
|
});
|
||||||
|
|
||||||
debugLastTrace(error);
|
debugThrowLastTrace(error);
|
||||||
|
|
||||||
throw error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EvalState::throwEvalError(const PosIdx pos, const char * s, const std::string & s2,
|
void EvalState::throwEvalError(const PosIdx pos, const char * s, const std::string & s2,
|
||||||
|
@ -912,9 +908,7 @@ void EvalState::throwEvalError(const PosIdx pos, const char * s, const std::stri
|
||||||
.errPos = positions[pos]
|
.errPos = positions[pos]
|
||||||
});
|
});
|
||||||
|
|
||||||
debugLastTrace(error);
|
debugThrowLastTrace(error);
|
||||||
|
|
||||||
throw error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EvalState::throwEvalError(const PosIdx pos, const char * s, const std::string & s2,
|
void EvalState::throwEvalError(const PosIdx pos, const char * s, const std::string & s2,
|
||||||
|
@ -925,10 +919,7 @@ void EvalState::throwEvalError(const PosIdx pos, const char * s, const std::stri
|
||||||
.errPos = positions[pos]
|
.errPos = positions[pos]
|
||||||
});
|
});
|
||||||
|
|
||||||
if (debuggerHook)
|
debugThrow(error, env, expr);
|
||||||
debuggerHook(&error, env, expr);
|
|
||||||
|
|
||||||
throw error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EvalState::throwEvalError(const PosIdx p1, const char * s, const Symbol sym, const PosIdx p2, Env & env, Expr & expr) const
|
void EvalState::throwEvalError(const PosIdx p1, const char * s, const Symbol sym, const PosIdx p2, Env & env, Expr & expr) const
|
||||||
|
@ -939,10 +930,7 @@ void EvalState::throwEvalError(const PosIdx p1, const char * s, const Symbol sym
|
||||||
.errPos = positions[p1]
|
.errPos = positions[p1]
|
||||||
});
|
});
|
||||||
|
|
||||||
if (debuggerHook)
|
debugThrow(error, env, expr);
|
||||||
debuggerHook(&error, env, expr);
|
|
||||||
|
|
||||||
throw error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EvalState::throwTypeError(const PosIdx pos, const char * s, const Value & v) const
|
void EvalState::throwTypeError(const PosIdx pos, const char * s, const Value & v) const
|
||||||
|
@ -952,9 +940,7 @@ void EvalState::throwTypeError(const PosIdx pos, const char * s, const Value & v
|
||||||
.errPos = positions[pos]
|
.errPos = positions[pos]
|
||||||
});
|
});
|
||||||
|
|
||||||
debugLastTrace(error);
|
debugThrowLastTrace(error);
|
||||||
|
|
||||||
throw error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EvalState::throwTypeError(const PosIdx pos, const char * s, const Value & v, Env & env, Expr & expr) const
|
void EvalState::throwTypeError(const PosIdx pos, const char * s, const Value & v, Env & env, Expr & expr) const
|
||||||
|
@ -964,10 +950,7 @@ void EvalState::throwTypeError(const PosIdx pos, const char * s, const Value & v
|
||||||
.errPos = positions[pos]
|
.errPos = positions[pos]
|
||||||
});
|
});
|
||||||
|
|
||||||
if (debuggerHook)
|
debugThrow(error, env, expr);
|
||||||
debuggerHook(&error, env, expr);
|
|
||||||
|
|
||||||
throw error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EvalState::throwTypeError(const PosIdx pos, const char * s) const
|
void EvalState::throwTypeError(const PosIdx pos, const char * s) const
|
||||||
|
@ -977,9 +960,7 @@ void EvalState::throwTypeError(const PosIdx pos, const char * s) const
|
||||||
.errPos = positions[pos]
|
.errPos = positions[pos]
|
||||||
});
|
});
|
||||||
|
|
||||||
debugLastTrace(error);
|
debugThrowLastTrace(error);
|
||||||
|
|
||||||
throw error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EvalState::throwTypeError(const PosIdx pos, const char * s, const ExprLambda & fun,
|
void EvalState::throwTypeError(const PosIdx pos, const char * s, const ExprLambda & fun,
|
||||||
|
@ -990,10 +971,7 @@ void EvalState::throwTypeError(const PosIdx pos, const char * s, const ExprLambd
|
||||||
.errPos = positions[pos]
|
.errPos = positions[pos]
|
||||||
});
|
});
|
||||||
|
|
||||||
if (debuggerHook)
|
debugThrow(error, env, expr);
|
||||||
debuggerHook(&error, env, expr);
|
|
||||||
|
|
||||||
throw error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EvalState::throwTypeError(const PosIdx pos, const Suggestions & suggestions, const char * s,
|
void EvalState::throwTypeError(const PosIdx pos, const Suggestions & suggestions, const char * s,
|
||||||
|
@ -1005,10 +983,7 @@ void EvalState::throwTypeError(const PosIdx pos, const Suggestions & suggestions
|
||||||
.suggestions = suggestions,
|
.suggestions = suggestions,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (debuggerHook)
|
debugThrow(error, env, expr);
|
||||||
debuggerHook(&error, env, expr);
|
|
||||||
|
|
||||||
throw error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EvalState::throwTypeError(const char * s, const Value & v, Env & env, Expr &expr) const
|
void EvalState::throwTypeError(const char * s, const Value & v, Env & env, Expr &expr) const
|
||||||
|
@ -1018,10 +993,7 @@ void EvalState::throwTypeError(const char * s, const Value & v, Env & env, Expr
|
||||||
.errPos = positions[expr.getPos()],
|
.errPos = positions[expr.getPos()],
|
||||||
});
|
});
|
||||||
|
|
||||||
if (debuggerHook)
|
debugThrow(error, env, expr);
|
||||||
debuggerHook(&error, env, expr);
|
|
||||||
|
|
||||||
throw error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EvalState::throwAssertionError(const PosIdx pos, const char * s, const std::string & s1, Env & env, Expr &expr) const
|
void EvalState::throwAssertionError(const PosIdx pos, const char * s, const std::string & s1, Env & env, Expr &expr) const
|
||||||
|
@ -1031,10 +1003,7 @@ void EvalState::throwAssertionError(const PosIdx pos, const char * s, const std:
|
||||||
.errPos = positions[pos]
|
.errPos = positions[pos]
|
||||||
});
|
});
|
||||||
|
|
||||||
if (debuggerHook)
|
debugThrow(error, env, expr);
|
||||||
debuggerHook(&error, env, expr);
|
|
||||||
|
|
||||||
throw error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EvalState::throwUndefinedVarError(const PosIdx pos, const char * s, const std::string & s1, Env & env, Expr &expr) const
|
void EvalState::throwUndefinedVarError(const PosIdx pos, const char * s, const std::string & s1, Env & env, Expr &expr) const
|
||||||
|
@ -1044,10 +1013,7 @@ void EvalState::throwUndefinedVarError(const PosIdx pos, const char * s, const s
|
||||||
.errPos = positions[pos]
|
.errPos = positions[pos]
|
||||||
});
|
});
|
||||||
|
|
||||||
if (debuggerHook)
|
debugThrow(error, env, expr);
|
||||||
debuggerHook(&error, env, expr);
|
|
||||||
|
|
||||||
throw error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EvalState::throwMissingArgumentError(const PosIdx pos, const char * s, const std::string & s1, Env & env, Expr &expr) const
|
void EvalState::throwMissingArgumentError(const PosIdx pos, const char * s, const std::string & s1, Env & env, Expr &expr) const
|
||||||
|
@ -1057,10 +1023,7 @@ void EvalState::throwMissingArgumentError(const PosIdx pos, const char * s, cons
|
||||||
.errPos = positions[pos]
|
.errPos = positions[pos]
|
||||||
});
|
});
|
||||||
|
|
||||||
if (debuggerHook)
|
debugThrow(error, env, expr);
|
||||||
debuggerHook(&error, env, expr);
|
|
||||||
|
|
||||||
throw error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EvalState::addErrorTrace(Error & e, const char * s, const std::string & s2) const
|
void EvalState::addErrorTrace(Error & e, const char * s, const std::string & s2) const
|
||||||
|
|
|
@ -127,7 +127,11 @@ public:
|
||||||
bool debugStop;
|
bool debugStop;
|
||||||
bool debugQuit;
|
bool debugQuit;
|
||||||
std::list<DebugTrace> debugTraces;
|
std::list<DebugTrace> debugTraces;
|
||||||
void debugLastTrace(Error & e) const;
|
|
||||||
|
[[gnu::noinline, gnu::noreturn]]
|
||||||
|
void debugThrow(const Error &error, const Env & env, const Expr & expr) const;
|
||||||
|
[[gnu::noinline, gnu::noreturn]]
|
||||||
|
void debugThrowLastTrace(Error & e) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SrcToStore srcToStore;
|
SrcToStore srcToStore;
|
||||||
|
|
|
@ -789,8 +789,7 @@ Path EvalState::findFile(SearchPath & searchPath, const std::string_view path, c
|
||||||
path),
|
path),
|
||||||
.errPos = positions[pos]
|
.errPos = positions[pos]
|
||||||
});
|
});
|
||||||
debugLastTrace(e);
|
debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -48,8 +48,7 @@ StringMap EvalState::realiseContext(const PathSet & context)
|
||||||
if (!store->isValidPath(ctx))
|
if (!store->isValidPath(ctx))
|
||||||
{
|
{
|
||||||
auto e = InvalidPathError(store->printStorePath(ctx));
|
auto e = InvalidPathError(store->printStorePath(ctx));
|
||||||
debugLastTrace(e);
|
debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
if (!outputName.empty() && ctx.isDerivation()) {
|
if (!outputName.empty() && ctx.isDerivation()) {
|
||||||
drvs.push_back({ctx, {outputName}});
|
drvs.push_back({ctx, {outputName}});
|
||||||
|
@ -65,8 +64,7 @@ StringMap EvalState::realiseContext(const PathSet & context)
|
||||||
auto e = Error(
|
auto e = Error(
|
||||||
"cannot build '%1%' during evaluation because the option 'allow-import-from-derivation' is disabled",
|
"cannot build '%1%' during evaluation because the option 'allow-import-from-derivation' is disabled",
|
||||||
store->printStorePath(drvs.begin()->drvPath));
|
store->printStorePath(drvs.begin()->drvPath));
|
||||||
debugLastTrace(e);
|
debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Build/substitute the context. */
|
/* Build/substitute the context. */
|
||||||
|
@ -82,8 +80,7 @@ StringMap EvalState::realiseContext(const PathSet & context)
|
||||||
if (!outputPath) {
|
if (!outputPath) {
|
||||||
auto e = Error("derivation '%s' does not have an output named '%s'",
|
auto e = Error("derivation '%s' does not have an output named '%s'",
|
||||||
store->printStorePath(drvPath), outputName);
|
store->printStorePath(drvPath), outputName);
|
||||||
debugLastTrace(e);
|
debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
res.insert_or_assign(
|
res.insert_or_assign(
|
||||||
downstreamPlaceholder(*store, drvPath, outputName),
|
downstreamPlaceholder(*store, drvPath, outputName),
|
||||||
|
@ -331,8 +328,7 @@ void prim_importNative(EvalState & state, const PosIdx pos, Value * * args, Valu
|
||||||
void *handle = dlopen(path.c_str(), RTLD_LAZY | RTLD_LOCAL);
|
void *handle = dlopen(path.c_str(), RTLD_LAZY | RTLD_LOCAL);
|
||||||
if (!handle) {
|
if (!handle) {
|
||||||
auto e = EvalError("could not open '%1%': %2%", path, dlerror());
|
auto e = EvalError("could not open '%1%': %2%", path, dlerror());
|
||||||
state.debugLastTrace(e);
|
state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dlerror();
|
dlerror();
|
||||||
|
@ -341,13 +337,11 @@ void prim_importNative(EvalState & state, const PosIdx pos, Value * * args, Valu
|
||||||
char *message = dlerror();
|
char *message = dlerror();
|
||||||
if (message) {
|
if (message) {
|
||||||
auto e = EvalError("could not load symbol '%1%' from '%2%': %3%", sym, path, message);
|
auto e = EvalError("could not load symbol '%1%' from '%2%': %3%", sym, path, message);
|
||||||
state.debugLastTrace(e);
|
state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
} else {
|
} else {
|
||||||
auto e = EvalError("symbol '%1%' from '%2%' resolved to NULL when a function pointer was expected",
|
auto e = EvalError("symbol '%1%' from '%2%' resolved to NULL when a function pointer was expected",
|
||||||
sym, path);
|
sym, path);
|
||||||
state.debugLastTrace(e);
|
state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -368,8 +362,7 @@ void prim_exec(EvalState & state, const PosIdx pos, Value * * args, Value & v)
|
||||||
.msg = hintfmt("at least one argument to 'exec' required"),
|
.msg = hintfmt("at least one argument to 'exec' required"),
|
||||||
.errPos = state.positions[pos]
|
.errPos = state.positions[pos]
|
||||||
});
|
});
|
||||||
state.debugLastTrace(e);
|
state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
PathSet context;
|
PathSet context;
|
||||||
auto program = state.coerceToString(pos, *elems[0], context, false, false).toOwned();
|
auto program = state.coerceToString(pos, *elems[0], context, false, false).toOwned();
|
||||||
|
@ -385,8 +378,7 @@ void prim_exec(EvalState & state, const PosIdx pos, Value * * args, Value & v)
|
||||||
program, e.path),
|
program, e.path),
|
||||||
.errPos = state.positions[pos]
|
.errPos = state.positions[pos]
|
||||||
});
|
});
|
||||||
state.debugLastTrace(ee);
|
state.debugThrowLastTrace(ee);
|
||||||
throw ee;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto output = runProgram(program, true, commandArgs);
|
auto output = runProgram(program, true, commandArgs);
|
||||||
|
@ -571,8 +563,7 @@ struct CompareValues
|
||||||
return v1->integer < v2->fpoint;
|
return v1->integer < v2->fpoint;
|
||||||
if (v1->type() != v2->type()) {
|
if (v1->type() != v2->type()) {
|
||||||
auto e = EvalError("cannot compare %1% with %2%", showType(*v1), showType(*v2));
|
auto e = EvalError("cannot compare %1% with %2%", showType(*v1), showType(*v2));
|
||||||
state.debugLastTrace(e);
|
state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
switch (v1->type()) {
|
switch (v1->type()) {
|
||||||
case nInt:
|
case nInt:
|
||||||
|
@ -596,8 +587,7 @@ struct CompareValues
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
auto e = EvalError("cannot compare %1% with %2%", showType(*v1), showType(*v2));
|
auto e = EvalError("cannot compare %1% with %2%", showType(*v1), showType(*v2));
|
||||||
state.debugLastTrace(e);
|
state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -632,8 +622,7 @@ static Bindings::iterator getAttr(
|
||||||
.msg = errorMsg,
|
.msg = errorMsg,
|
||||||
.errPos = state.positions[pos],
|
.errPos = state.positions[pos],
|
||||||
});
|
});
|
||||||
state.debugLastTrace(e);
|
state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
} else {
|
} else {
|
||||||
auto e = TypeError({
|
auto e = TypeError({
|
||||||
.msg = errorMsg,
|
.msg = errorMsg,
|
||||||
|
@ -643,8 +632,7 @@ static Bindings::iterator getAttr(
|
||||||
// Adding another trace for the function name to make it clear
|
// Adding another trace for the function name to make it clear
|
||||||
// which call received wrong arguments.
|
// which call received wrong arguments.
|
||||||
e.addTrace(state.positions[pos], hintfmt("while invoking '%s'", funcName));
|
e.addTrace(state.positions[pos], hintfmt("while invoking '%s'", funcName));
|
||||||
state.debugLastTrace(e);
|
state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -702,8 +690,7 @@ static void prim_genericClosure(EvalState & state, const PosIdx pos, Value * * a
|
||||||
.msg = hintfmt("attribute 'key' required"),
|
.msg = hintfmt("attribute 'key' required"),
|
||||||
.errPos = state.positions[pos]
|
.errPos = state.positions[pos]
|
||||||
});
|
});
|
||||||
state.debugLastTrace(e);
|
state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
state.forceValue(*key->value, pos);
|
state.forceValue(*key->value, pos);
|
||||||
|
|
||||||
|
@ -807,8 +794,7 @@ static RegisterPrimOp primop_abort({
|
||||||
auto s = state.coerceToString(pos, *args[0], context).toOwned();
|
auto s = state.coerceToString(pos, *args[0], context).toOwned();
|
||||||
{
|
{
|
||||||
auto e = Abort("evaluation aborted with the following error message: '%1%'", s);
|
auto e = Abort("evaluation aborted with the following error message: '%1%'", s);
|
||||||
state.debugLastTrace(e);
|
state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -828,8 +814,7 @@ static RegisterPrimOp primop_throw({
|
||||||
PathSet context;
|
PathSet context;
|
||||||
auto s = state.coerceToString(pos, *args[0], context).toOwned();
|
auto s = state.coerceToString(pos, *args[0], context).toOwned();
|
||||||
auto e = ThrownError(s);
|
auto e = ThrownError(s);
|
||||||
state.debugLastTrace(e);
|
state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -893,6 +878,7 @@ static RegisterPrimOp primop_floor({
|
||||||
* else => {success=false; value=false;} */
|
* else => {success=false; value=false;} */
|
||||||
static void prim_tryEval(EvalState & state, const PosIdx pos, Value * * args, Value & v)
|
static void prim_tryEval(EvalState & state, const PosIdx pos, Value * * args, Value & v)
|
||||||
{
|
{
|
||||||
|
std::cout << "priatraynasdf0" << std::endl;
|
||||||
auto attrs = state.buildBindings(2);
|
auto attrs = state.buildBindings(2);
|
||||||
auto saveDebuggerHook = debuggerHook;
|
auto saveDebuggerHook = debuggerHook;
|
||||||
debuggerHook = nullptr;
|
debuggerHook = nullptr;
|
||||||
|
@ -900,7 +886,15 @@ static void prim_tryEval(EvalState & state, const PosIdx pos, Value * * args, Va
|
||||||
state.forceValue(*args[0], pos);
|
state.forceValue(*args[0], pos);
|
||||||
attrs.insert(state.sValue, args[0]);
|
attrs.insert(state.sValue, args[0]);
|
||||||
attrs.alloc("success").mkBool(true);
|
attrs.alloc("success").mkBool(true);
|
||||||
|
std::cout << "priatraynasdf0000" << std::endl;
|
||||||
} catch (AssertionError & e) {
|
} catch (AssertionError & e) {
|
||||||
|
std::cout << "priatraynasdf" << std::endl;
|
||||||
|
|
||||||
|
attrs.alloc(state.sValue).mkBool(false);
|
||||||
|
attrs.alloc("success").mkBool(false);
|
||||||
|
} catch (Error & e) {
|
||||||
|
std::cout << "priatraERASERynasdf" << std::endl;
|
||||||
|
|
||||||
attrs.alloc(state.sValue).mkBool(false);
|
attrs.alloc(state.sValue).mkBool(false);
|
||||||
attrs.alloc("success").mkBool(false);
|
attrs.alloc("success").mkBool(false);
|
||||||
}
|
}
|
||||||
|
@ -1092,8 +1086,7 @@ static void prim_derivationStrict(EvalState & state, const PosIdx pos, Value * *
|
||||||
.msg = hintfmt("invalid value '%s' for 'outputHashMode' attribute", s),
|
.msg = hintfmt("invalid value '%s' for 'outputHashMode' attribute", s),
|
||||||
.errPos = state.positions[posDrvName]
|
.errPos = state.positions[posDrvName]
|
||||||
});
|
});
|
||||||
state.debugLastTrace(e);
|
state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1106,8 +1099,7 @@ static void prim_derivationStrict(EvalState & state, const PosIdx pos, Value * *
|
||||||
.msg = hintfmt("duplicate derivation output '%1%'", j),
|
.msg = hintfmt("duplicate derivation output '%1%'", j),
|
||||||
.errPos = state.positions[posDrvName]
|
.errPos = state.positions[posDrvName]
|
||||||
});
|
});
|
||||||
state.debugLastTrace(e);
|
state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
/* !!! Check whether j is a valid attribute
|
/* !!! Check whether j is a valid attribute
|
||||||
name. */
|
name. */
|
||||||
|
@ -1120,8 +1112,7 @@ static void prim_derivationStrict(EvalState & state, const PosIdx pos, Value * *
|
||||||
.msg = hintfmt("invalid derivation output name 'drv'" ),
|
.msg = hintfmt("invalid derivation output name 'drv'" ),
|
||||||
.errPos = state.positions[posDrvName]
|
.errPos = state.positions[posDrvName]
|
||||||
});
|
});
|
||||||
state.debugLastTrace(e);
|
state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
outputs.insert(j);
|
outputs.insert(j);
|
||||||
}
|
}
|
||||||
|
@ -1131,8 +1122,7 @@ static void prim_derivationStrict(EvalState & state, const PosIdx pos, Value * *
|
||||||
.msg = hintfmt("derivation cannot have an empty set of outputs"),
|
.msg = hintfmt("derivation cannot have an empty set of outputs"),
|
||||||
.errPos = state.positions[posDrvName]
|
.errPos = state.positions[posDrvName]
|
||||||
});
|
});
|
||||||
state.debugLastTrace(e);
|
state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1263,8 +1253,7 @@ static void prim_derivationStrict(EvalState & state, const PosIdx pos, Value * *
|
||||||
.msg = hintfmt("required attribute 'builder' missing"),
|
.msg = hintfmt("required attribute 'builder' missing"),
|
||||||
.errPos = state.positions[posDrvName]
|
.errPos = state.positions[posDrvName]
|
||||||
});
|
});
|
||||||
state.debugLastTrace(e);
|
state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (drv.platform == "")
|
if (drv.platform == "")
|
||||||
|
@ -1273,8 +1262,7 @@ static void prim_derivationStrict(EvalState & state, const PosIdx pos, Value * *
|
||||||
.msg = hintfmt("required attribute 'system' missing"),
|
.msg = hintfmt("required attribute 'system' missing"),
|
||||||
.errPos = state.positions[posDrvName]
|
.errPos = state.positions[posDrvName]
|
||||||
});
|
});
|
||||||
state.debugLastTrace(e);
|
state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check whether the derivation name is valid. */
|
/* Check whether the derivation name is valid. */
|
||||||
|
@ -1284,8 +1272,7 @@ static void prim_derivationStrict(EvalState & state, const PosIdx pos, Value * *
|
||||||
.msg = hintfmt("derivation names are not allowed to end in '%s'", drvExtension),
|
.msg = hintfmt("derivation names are not allowed to end in '%s'", drvExtension),
|
||||||
.errPos = state.positions[posDrvName]
|
.errPos = state.positions[posDrvName]
|
||||||
});
|
});
|
||||||
state.debugLastTrace(e);
|
state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (outputHash) {
|
if (outputHash) {
|
||||||
|
@ -1299,8 +1286,7 @@ static void prim_derivationStrict(EvalState & state, const PosIdx pos, Value * *
|
||||||
.msg = hintfmt("multiple outputs are not supported in fixed-output derivations"),
|
.msg = hintfmt("multiple outputs are not supported in fixed-output derivations"),
|
||||||
.errPos = state.positions[posDrvName]
|
.errPos = state.positions[posDrvName]
|
||||||
});
|
});
|
||||||
state.debugLastTrace(e);
|
state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto h = newHashAllowEmpty(*outputHash, parseHashTypeOpt(outputHashAlgo));
|
auto h = newHashAllowEmpty(*outputHash, parseHashTypeOpt(outputHashAlgo));
|
||||||
|
@ -1474,8 +1460,7 @@ static void prim_storePath(EvalState & state, const PosIdx pos, Value * * args,
|
||||||
.msg = hintfmt("'%s' is not allowed in pure evaluation mode", "builtins.storePath"),
|
.msg = hintfmt("'%s' is not allowed in pure evaluation mode", "builtins.storePath"),
|
||||||
.errPos = state.positions[pos]
|
.errPos = state.positions[pos]
|
||||||
});
|
});
|
||||||
state.debugLastTrace(e);
|
state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PathSet context;
|
PathSet context;
|
||||||
|
@ -1490,8 +1475,7 @@ static void prim_storePath(EvalState & state, const PosIdx pos, Value * * args,
|
||||||
.msg = hintfmt("path '%1%' is not in the Nix store", path),
|
.msg = hintfmt("path '%1%' is not in the Nix store", path),
|
||||||
.errPos = state.positions[pos]
|
.errPos = state.positions[pos]
|
||||||
});
|
});
|
||||||
state.debugLastTrace(e);
|
state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
auto path2 = state.store->toStorePath(path).first;
|
auto path2 = state.store->toStorePath(path).first;
|
||||||
if (!settings.readOnlyMode)
|
if (!settings.readOnlyMode)
|
||||||
|
@ -1597,8 +1581,7 @@ static void prim_readFile(EvalState & state, const PosIdx pos, Value * * args, V
|
||||||
if (s.find((char) 0) != std::string::npos)
|
if (s.find((char) 0) != std::string::npos)
|
||||||
{
|
{
|
||||||
auto e = Error("the contents of the file '%1%' cannot be represented as a Nix string", path);
|
auto e = Error("the contents of the file '%1%' cannot be represented as a Nix string", path);
|
||||||
state.debugLastTrace(e);
|
state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
StorePathSet refs;
|
StorePathSet refs;
|
||||||
if (state.store->isInStore(path)) {
|
if (state.store->isInStore(path)) {
|
||||||
|
@ -1655,8 +1638,7 @@ static void prim_findFile(EvalState & state, const PosIdx pos, Value * * args, V
|
||||||
.msg = hintfmt("cannot find '%1%', since path '%2%' is not valid", path, e.path),
|
.msg = hintfmt("cannot find '%1%', since path '%2%' is not valid", path, e.path),
|
||||||
.errPos = state.positions[pos]
|
.errPos = state.positions[pos]
|
||||||
});
|
});
|
||||||
state.debugLastTrace(ee);
|
state.debugThrowLastTrace(ee);
|
||||||
throw ee;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1685,8 +1667,7 @@ static void prim_hashFile(EvalState & state, const PosIdx pos, Value * * args, V
|
||||||
.msg = hintfmt("unknown hash type '%1%'", type),
|
.msg = hintfmt("unknown hash type '%1%'", type),
|
||||||
.errPos = state.positions[pos]
|
.errPos = state.positions[pos]
|
||||||
});
|
});
|
||||||
state.debugLastTrace(e);
|
state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto path = realisePath(state, pos, *args[1]);
|
auto path = realisePath(state, pos, *args[1]);
|
||||||
|
@ -1932,8 +1913,7 @@ static void prim_toFile(EvalState & state, const PosIdx pos, Value * * args, Val
|
||||||
name, path),
|
name, path),
|
||||||
.errPos = state.positions[pos]
|
.errPos = state.positions[pos]
|
||||||
});
|
});
|
||||||
state.debugLastTrace(e);
|
state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
refs.insert(state.store->parseStorePath(path));
|
refs.insert(state.store->parseStorePath(path));
|
||||||
}
|
}
|
||||||
|
@ -2094,8 +2074,7 @@ static void addPath(
|
||||||
if (expectedHash && expectedStorePath != dstPath)
|
if (expectedHash && expectedStorePath != dstPath)
|
||||||
{
|
{
|
||||||
auto e = Error("store path mismatch in (possibly filtered) path added from '%s'", path);
|
auto e = Error("store path mismatch in (possibly filtered) path added from '%s'", path);
|
||||||
state.debugLastTrace(e);
|
state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
state.allowAndSetStorePathString(dstPath, v);
|
state.allowAndSetStorePathString(dstPath, v);
|
||||||
} else
|
} else
|
||||||
|
@ -2121,8 +2100,7 @@ static void prim_filterSource(EvalState & state, const PosIdx pos, Value * * arg
|
||||||
showType(*args[0])),
|
showType(*args[0])),
|
||||||
.errPos = state.positions[pos]
|
.errPos = state.positions[pos]
|
||||||
});
|
});
|
||||||
state.debugLastTrace(e);
|
state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
addPath(state, pos, std::string(baseNameOf(path)), path, args[0], FileIngestionMethod::Recursive, std::nullopt, v, context);
|
addPath(state, pos, std::string(baseNameOf(path)), path, args[0], FileIngestionMethod::Recursive, std::nullopt, v, context);
|
||||||
|
@ -2212,8 +2190,7 @@ static void prim_path(EvalState & state, const PosIdx pos, Value * * args, Value
|
||||||
.msg = hintfmt("unsupported argument '%1%' to 'addPath'", state.symbols[attr.name]),
|
.msg = hintfmt("unsupported argument '%1%' to 'addPath'", state.symbols[attr.name]),
|
||||||
.errPos = state.positions[attr.pos]
|
.errPos = state.positions[attr.pos]
|
||||||
});
|
});
|
||||||
state.debugLastTrace(e);
|
state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (path.empty())
|
if (path.empty())
|
||||||
|
@ -2222,8 +2199,7 @@ static void prim_path(EvalState & state, const PosIdx pos, Value * * args, Value
|
||||||
.msg = hintfmt("'path' required"),
|
.msg = hintfmt("'path' required"),
|
||||||
.errPos = state.positions[pos]
|
.errPos = state.positions[pos]
|
||||||
});
|
});
|
||||||
state.debugLastTrace(e);
|
state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
if (name.empty())
|
if (name.empty())
|
||||||
name = baseNameOf(path);
|
name = baseNameOf(path);
|
||||||
|
@ -2601,8 +2577,7 @@ static void prim_functionArgs(EvalState & state, const PosIdx pos, Value * * arg
|
||||||
.msg = hintfmt("'functionArgs' requires a function"),
|
.msg = hintfmt("'functionArgs' requires a function"),
|
||||||
.errPos = state.positions[pos]
|
.errPos = state.positions[pos]
|
||||||
});
|
});
|
||||||
state.debugLastTrace(e);
|
state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!args[0]->lambda.fun->hasFormals()) {
|
if (!args[0]->lambda.fun->hasFormals()) {
|
||||||
|
@ -2691,8 +2666,7 @@ static void prim_zipAttrsWith(EvalState & state, const PosIdx pos, Value * * arg
|
||||||
attrsSeen[attr.name].first++;
|
attrsSeen[attr.name].first++;
|
||||||
} catch (TypeError & e) {
|
} catch (TypeError & e) {
|
||||||
e.addTrace(state.positions[pos], hintfmt("while invoking '%s'", "zipAttrsWith"));
|
e.addTrace(state.positions[pos], hintfmt("while invoking '%s'", "zipAttrsWith"));
|
||||||
state.debugLastTrace(e);
|
state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2784,8 +2758,7 @@ static void elemAt(EvalState & state, const PosIdx pos, Value & list, int n, Val
|
||||||
.msg = hintfmt("list index %1% is out of bounds", n),
|
.msg = hintfmt("list index %1% is out of bounds", n),
|
||||||
.errPos = state.positions[pos]
|
.errPos = state.positions[pos]
|
||||||
});
|
});
|
||||||
state.debugLastTrace(e);
|
state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
state.forceValue(*list.listElems()[n], pos);
|
state.forceValue(*list.listElems()[n], pos);
|
||||||
v = *list.listElems()[n];
|
v = *list.listElems()[n];
|
||||||
|
@ -2836,8 +2809,7 @@ static void prim_tail(EvalState & state, const PosIdx pos, Value * * args, Value
|
||||||
.msg = hintfmt("'tail' called on an empty list"),
|
.msg = hintfmt("'tail' called on an empty list"),
|
||||||
.errPos = state.positions[pos]
|
.errPos = state.positions[pos]
|
||||||
});
|
});
|
||||||
state.debugLastTrace(e);
|
state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
state.mkList(v, args[0]->listSize() - 1);
|
state.mkList(v, args[0]->listSize() - 1);
|
||||||
|
@ -3078,8 +3050,7 @@ static void prim_genList(EvalState & state, const PosIdx pos, Value * * args, Va
|
||||||
.msg = hintfmt("cannot create list of size %1%", len),
|
.msg = hintfmt("cannot create list of size %1%", len),
|
||||||
.errPos = state.positions[pos]
|
.errPos = state.positions[pos]
|
||||||
});
|
});
|
||||||
state.debugLastTrace(e);
|
state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
state.mkList(v, len);
|
state.mkList(v, len);
|
||||||
|
@ -3289,8 +3260,7 @@ static void prim_concatMap(EvalState & state, const PosIdx pos, Value * * args,
|
||||||
state.forceList(lists[n], lists[n].determinePos(args[0]->determinePos(pos)));
|
state.forceList(lists[n], lists[n].determinePos(args[0]->determinePos(pos)));
|
||||||
} catch (TypeError &e) {
|
} catch (TypeError &e) {
|
||||||
e.addTrace(state.positions[pos], hintfmt("while invoking '%s'", "concatMap"));
|
e.addTrace(state.positions[pos], hintfmt("while invoking '%s'", "concatMap"));
|
||||||
state.debugLastTrace(e);
|
state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
len += lists[n].listSize();
|
len += lists[n].listSize();
|
||||||
}
|
}
|
||||||
|
@ -3390,8 +3360,7 @@ static void prim_div(EvalState & state, const PosIdx pos, Value * * args, Value
|
||||||
.msg = hintfmt("division by zero"),
|
.msg = hintfmt("division by zero"),
|
||||||
.errPos = state.positions[pos]
|
.errPos = state.positions[pos]
|
||||||
});
|
});
|
||||||
state.debugLastTrace(e);
|
state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[0]->type() == nFloat || args[1]->type() == nFloat) {
|
if (args[0]->type() == nFloat || args[1]->type() == nFloat) {
|
||||||
|
@ -3406,8 +3375,7 @@ static void prim_div(EvalState & state, const PosIdx pos, Value * * args, Value
|
||||||
.msg = hintfmt("overflow in integer division"),
|
.msg = hintfmt("overflow in integer division"),
|
||||||
.errPos = state.positions[pos]
|
.errPos = state.positions[pos]
|
||||||
});
|
});
|
||||||
state.debugLastTrace(e);
|
state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
v.mkInt(i1 / i2);
|
v.mkInt(i1 / i2);
|
||||||
|
@ -3541,8 +3509,7 @@ static void prim_substring(EvalState & state, const PosIdx pos, Value * * args,
|
||||||
.msg = hintfmt("negative start position in 'substring'"),
|
.msg = hintfmt("negative start position in 'substring'"),
|
||||||
.errPos = state.positions[pos]
|
.errPos = state.positions[pos]
|
||||||
});
|
});
|
||||||
state.debugLastTrace(e);
|
state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
v.mkString((unsigned int) start >= s->size() ? "" : s->substr(start, len), context);
|
v.mkString((unsigned int) start >= s->size() ? "" : s->substr(start, len), context);
|
||||||
|
@ -3596,8 +3563,7 @@ static void prim_hashString(EvalState & state, const PosIdx pos, Value * * args,
|
||||||
.msg = hintfmt("unknown hash type '%1%'", type),
|
.msg = hintfmt("unknown hash type '%1%'", type),
|
||||||
.errPos = state.positions[pos]
|
.errPos = state.positions[pos]
|
||||||
});
|
});
|
||||||
state.debugLastTrace(e);
|
state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PathSet context; // discarded
|
PathSet context; // discarded
|
||||||
|
@ -3672,15 +3638,13 @@ void prim_match(EvalState & state, const PosIdx pos, Value * * args, Value & v)
|
||||||
.msg = hintfmt("memory limit exceeded by regular expression '%s'", re),
|
.msg = hintfmt("memory limit exceeded by regular expression '%s'", re),
|
||||||
.errPos = state.positions[pos]
|
.errPos = state.positions[pos]
|
||||||
});
|
});
|
||||||
state.debugLastTrace(e);
|
state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
} else {
|
} else {
|
||||||
auto e = EvalError({
|
auto e = EvalError({
|
||||||
.msg = hintfmt("invalid regular expression '%s'", re),
|
.msg = hintfmt("invalid regular expression '%s'", re),
|
||||||
.errPos = state.positions[pos]
|
.errPos = state.positions[pos]
|
||||||
});
|
});
|
||||||
state.debugLastTrace(e);
|
state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3781,15 +3745,13 @@ void prim_split(EvalState & state, const PosIdx pos, Value * * args, Value & v)
|
||||||
.msg = hintfmt("memory limit exceeded by regular expression '%s'", re),
|
.msg = hintfmt("memory limit exceeded by regular expression '%s'", re),
|
||||||
.errPos = state.positions[pos]
|
.errPos = state.positions[pos]
|
||||||
});
|
});
|
||||||
state.debugLastTrace(e);
|
state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
} else {
|
} else {
|
||||||
auto e = EvalError({
|
auto e = EvalError({
|
||||||
.msg = hintfmt("invalid regular expression '%s'", re),
|
.msg = hintfmt("invalid regular expression '%s'", re),
|
||||||
.errPos = state.positions[pos]
|
.errPos = state.positions[pos]
|
||||||
});
|
});
|
||||||
state.debugLastTrace(e);
|
state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3871,8 +3833,7 @@ static void prim_replaceStrings(EvalState & state, const PosIdx pos, Value * * a
|
||||||
.msg = hintfmt("'from' and 'to' arguments to 'replaceStrings' have different lengths"),
|
.msg = hintfmt("'from' and 'to' arguments to 'replaceStrings' have different lengths"),
|
||||||
.errPos = state.positions[pos]
|
.errPos = state.positions[pos]
|
||||||
});
|
});
|
||||||
state.debugLastTrace(e);
|
state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> from;
|
std::vector<std::string> from;
|
||||||
|
|
|
@ -113,8 +113,7 @@ static void fetchTree(
|
||||||
.msg = hintfmt("unexpected attribute 'type'"),
|
.msg = hintfmt("unexpected attribute 'type'"),
|
||||||
.errPos = state.positions[pos]
|
.errPos = state.positions[pos]
|
||||||
});
|
});
|
||||||
state.debugLastTrace(e);
|
state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
type = state.forceStringNoCtx(*aType->value, aType->pos);
|
type = state.forceStringNoCtx(*aType->value, aType->pos);
|
||||||
} else if (!type)
|
} else if (!type)
|
||||||
|
@ -123,8 +122,7 @@ static void fetchTree(
|
||||||
.msg = hintfmt("attribute 'type' is missing in call to 'fetchTree'"),
|
.msg = hintfmt("attribute 'type' is missing in call to 'fetchTree'"),
|
||||||
.errPos = state.positions[pos]
|
.errPos = state.positions[pos]
|
||||||
});
|
});
|
||||||
state.debugLastTrace(e);
|
state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
attrs.emplace("type", type.value());
|
attrs.emplace("type", type.value());
|
||||||
|
@ -149,8 +147,7 @@ static void fetchTree(
|
||||||
{
|
{
|
||||||
auto e = TypeError("fetchTree argument '%s' is %s while a string, Boolean or integer is expected",
|
auto e = TypeError("fetchTree argument '%s' is %s while a string, Boolean or integer is expected",
|
||||||
state.symbols[attr.name], showType(*attr.value));
|
state.symbols[attr.name], showType(*attr.value));
|
||||||
state.debugLastTrace(e);
|
state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,8 +158,7 @@ static void fetchTree(
|
||||||
.msg = hintfmt("attribute 'name' isn’t supported in call to 'fetchTree'"),
|
.msg = hintfmt("attribute 'name' isn’t supported in call to 'fetchTree'"),
|
||||||
.errPos = state.positions[pos]
|
.errPos = state.positions[pos]
|
||||||
});
|
});
|
||||||
state.debugLastTrace(e);
|
state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
input = fetchers::Input::fromAttrs(std::move(attrs));
|
input = fetchers::Input::fromAttrs(std::move(attrs));
|
||||||
|
@ -185,8 +181,7 @@ static void fetchTree(
|
||||||
if (evalSettings.pureEval && !input.isLocked())
|
if (evalSettings.pureEval && !input.isLocked())
|
||||||
{
|
{
|
||||||
auto e = EvalError("in pure evaluation mode, 'fetchTree' requires a locked input, at %s", state.positions[pos]);
|
auto e = EvalError("in pure evaluation mode, 'fetchTree' requires a locked input, at %s", state.positions[pos]);
|
||||||
state.debugLastTrace(e);
|
state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto [tree, input2] = input.fetch(state.store);
|
auto [tree, input2] = input.fetch(state.store);
|
||||||
|
@ -231,8 +226,7 @@ static void fetch(EvalState & state, const PosIdx pos, Value * * args, Value & v
|
||||||
.msg = hintfmt("unsupported argument '%s' to '%s'", n, who),
|
.msg = hintfmt("unsupported argument '%s' to '%s'", n, who),
|
||||||
.errPos = state.positions[attr.pos]
|
.errPos = state.positions[attr.pos]
|
||||||
});
|
});
|
||||||
state.debugLastTrace(e);
|
state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,8 +236,7 @@ static void fetch(EvalState & state, const PosIdx pos, Value * * args, Value & v
|
||||||
.msg = hintfmt("'url' argument required"),
|
.msg = hintfmt("'url' argument required"),
|
||||||
.errPos = state.positions[pos]
|
.errPos = state.positions[pos]
|
||||||
});
|
});
|
||||||
state.debugLastTrace(e);
|
state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
url = state.forceStringNoCtx(*args[0], pos);
|
url = state.forceStringNoCtx(*args[0], pos);
|
||||||
|
@ -258,8 +251,7 @@ static void fetch(EvalState & state, const PosIdx pos, Value * * args, Value & v
|
||||||
if (evalSettings.pureEval && !expectedHash)
|
if (evalSettings.pureEval && !expectedHash)
|
||||||
{
|
{
|
||||||
auto e = EvalError("in pure evaluation mode, '%s' requires a 'sha256' argument", who);
|
auto e = EvalError("in pure evaluation mode, '%s' requires a 'sha256' argument", who);
|
||||||
state.debugLastTrace(e);
|
state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// early exit if pinned and already in the store
|
// early exit if pinned and already in the store
|
||||||
|
@ -290,8 +282,7 @@ static void fetch(EvalState & state, const PosIdx pos, Value * * args, Value & v
|
||||||
{
|
{
|
||||||
auto e = EvalError((unsigned int) 102, "hash mismatch in file downloaded from '%s':\n specified: %s\n got: %s",
|
auto e = EvalError((unsigned int) 102, "hash mismatch in file downloaded from '%s':\n specified: %s\n got: %s",
|
||||||
*url, expectedHash->to_string(Base32, true), hash.to_string(Base32, true));
|
*url, expectedHash->to_string(Base32, true), hash.to_string(Base32, true));
|
||||||
state.debugLastTrace(e);
|
state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,7 @@ void printValueAsJSON(EvalState & state, bool strict,
|
||||||
.errPos = state.positions[v.determinePos(pos)]
|
.errPos = state.positions[v.determinePos(pos)]
|
||||||
});
|
});
|
||||||
e.addTrace(state.positions[pos], hintfmt("message for the trace"));
|
e.addTrace(state.positions[pos], hintfmt("message for the trace"));
|
||||||
state.debugLastTrace(e);
|
state.debugThrowLastTrace(e);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -101,8 +101,7 @@ void ExternalValueBase::printValueAsJSON(EvalState & state, bool strict,
|
||||||
JSONPlaceholder & out, PathSet & context) const
|
JSONPlaceholder & out, PathSet & context) const
|
||||||
{
|
{
|
||||||
auto e = TypeError("cannot convert %1% to JSON", showType());
|
auto e = TypeError("cannot convert %1% to JSON", showType());
|
||||||
state.debugLastTrace(e);
|
state.debugThrowLastTrace(e);
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue