diff --git a/src/libexpr/eval-error.cc b/src/libexpr/eval-error.cc index f4cdeec5c..8db03610b 100644 --- a/src/libexpr/eval-error.cc +++ b/src/libexpr/eval-error.cc @@ -28,15 +28,7 @@ template EvalErrorBuilder & EvalErrorBuilder::withTrace(PosIdx pos, const std::string_view text) { error.err.traces.push_front( - Trace{.pos = error.state.positions[pos], .hint = HintFmt(std::string(text)), .frame = false}); - return *this; -} - -template -EvalErrorBuilder & EvalErrorBuilder::withFrameTrace(PosIdx pos, const std::string_view text) -{ - error.err.traces.push_front( - Trace{.pos = error.state.positions[pos], .hint = HintFmt(std::string(text)), .frame = true}); + Trace{.pos = error.state.positions[pos], .hint = HintFmt(std::string(text))}); return *this; } @@ -63,9 +55,9 @@ EvalErrorBuilder & EvalErrorBuilder::withFrame(const Env & env, const Expr } template -EvalErrorBuilder & EvalErrorBuilder::addTrace(PosIdx pos, HintFmt hint, bool frame) +EvalErrorBuilder & EvalErrorBuilder::addTrace(PosIdx pos, HintFmt hint) { - error.addTrace(error.state.positions[pos], hint, frame); + error.addTrace(error.state.positions[pos], hint); return *this; } diff --git a/src/libexpr/eval-error.hh b/src/libexpr/eval-error.hh index 392902ad2..7e0cbe982 100644 --- a/src/libexpr/eval-error.hh +++ b/src/libexpr/eval-error.hh @@ -89,7 +89,7 @@ public: [[nodiscard, gnu::noinline]] EvalErrorBuilder & withFrame(const Env & e, const Expr & ex); - [[nodiscard, gnu::noinline]] EvalErrorBuilder & addTrace(PosIdx pos, HintFmt hint, bool frame = false); + [[nodiscard, gnu::noinline]] EvalErrorBuilder & addTrace(PosIdx pos, HintFmt hint); template [[nodiscard, gnu::noinline]] EvalErrorBuilder & diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index 205d40b83..54b1125ce 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -811,9 +811,9 @@ void EvalState::addErrorTrace(Error & e, const char * s, const std::string & s2) e.addTrace(nullptr, s, s2); } -void EvalState::addErrorTrace(Error & e, const PosIdx pos, const char * s, const std::string & s2, bool frame) const +void EvalState::addErrorTrace(Error & e, const PosIdx pos, const char * s, const std::string & s2) const { - e.addTrace(positions[pos], HintFmt(s, s2), frame); + e.addTrace(positions[pos], HintFmt(s, s2)); } template @@ -1587,9 +1587,8 @@ void EvalState::callFunction(Value & fun, size_t nrArgs, Value * * args, Value & "while calling %s", lambda.name ? concatStrings("'", symbols[lambda.name], "'") - : "anonymous lambda", - true); - if (pos) addErrorTrace(e, pos, "from call site%s", "", true); + : "anonymous lambda"); + if (pos) addErrorTrace(e, pos, "from call site%s", ""); } throw; } diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh index 42fe0d3e4..80b583eb1 100644 --- a/src/libexpr/eval.hh +++ b/src/libexpr/eval.hh @@ -435,7 +435,7 @@ public: [[gnu::noinline]] void addErrorTrace(Error & e, const char * s, const std::string & s2) const; [[gnu::noinline]] - void addErrorTrace(Error & e, const PosIdx pos, const char * s, const std::string & s2, bool frame = false) const; + void addErrorTrace(Error & e, const PosIdx pos, const char * s, const std::string & s2) const; public: /** diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc index 42cfa4917..835afba82 100644 --- a/src/libexpr/primops.cc +++ b/src/libexpr/primops.cc @@ -811,7 +811,7 @@ static void prim_addErrorContext(EvalState & state, const PosIdx pos, Value * * auto message = state.coerceToString(pos, *args[0], context, "while evaluating the error message passed to builtins.addErrorContext", false, false).toOwned(); - e.addTrace(nullptr, HintFmt(message), true); + e.addTrace(nullptr, HintFmt(message)); throw; } } @@ -1075,7 +1075,7 @@ static void prim_derivationStrict(EvalState & state, const PosIdx pos, Value * * e.addTrace(nullptr, HintFmt( "while evaluating derivation '%s'\n" " whose name attribute is located at %s", - drvName, pos), true); + drvName, pos)); throw; } } @@ -1233,8 +1233,7 @@ drvName, Bindings * attrs, Value & v) } catch (Error & e) { e.addTrace(state.positions[i->pos], - HintFmt("while evaluating attribute '%1%' of derivation '%2%'", key, drvName), - true); + HintFmt("while evaluating attribute '%1%' of derivation '%2%'", key, drvName)); throw; } } diff --git a/src/libutil/error.cc b/src/libutil/error.cc index d2a3d2114..d1e864a1a 100644 --- a/src/libutil/error.cc +++ b/src/libutil/error.cc @@ -11,9 +11,9 @@ namespace nix { -void BaseError::addTrace(std::shared_ptr && e, HintFmt hint, bool frame) +void BaseError::addTrace(std::shared_ptr && e, HintFmt hint) { - err.traces.push_front(Trace { .pos = std::move(e), .hint = hint, .frame = frame }); + err.traces.push_front(Trace { .pos = std::move(e), .hint = hint }); } void throwExceptionSelfCheck(){ @@ -61,8 +61,7 @@ inline bool operator<(const Trace& lhs, const Trace& rhs) // This formats a freshly formatted hint string and then throws it away, which // shouldn't be much of a problem because it only runs when pos is equal, and this function is // used for trace printing, which is infrequent. - return std::forward_as_tuple(lhs.hint.str(), lhs.frame) - < std::forward_as_tuple(rhs.hint.str(), rhs.frame); + return lhs.hint.str() < rhs.hint.str(); } inline bool operator> (const Trace& lhs, const Trace& rhs) { return rhs < lhs; } inline bool operator<=(const Trace& lhs, const Trace& rhs) { return !(lhs > rhs); } diff --git a/src/libutil/error.hh b/src/libutil/error.hh index 2e5de5d32..89f5ad021 100644 --- a/src/libutil/error.hh +++ b/src/libutil/error.hh @@ -64,7 +64,6 @@ void printCodeLines(std::ostream & out, struct Trace { std::shared_ptr pos; HintFmt hint; - bool frame; }; inline bool operator<(const Trace& lhs, const Trace& rhs); @@ -162,7 +161,7 @@ public: addTrace(std::move(e), HintFmt(std::string(fs), args...)); } - void addTrace(std::shared_ptr && e, HintFmt hint, bool frame = false); + void addTrace(std::shared_ptr && e, HintFmt hint); bool hasTrace() const { return !err.traces.empty(); }