diff options
author | Ben Burdette <bburdette@protonmail.com> | 2022-04-08 15:46:12 -0600 |
---|---|---|
committer | Ben Burdette <bburdette@protonmail.com> | 2022-04-08 15:46:12 -0600 |
commit | 27d45f9eb3c151afed8a20f1adc1d4dd1a200f09 (patch) | |
tree | 3e618661c43e46c0d76c93db550b957b40a5bb30 /src | |
parent | a86c2a8481c5bedb992d7126bc342a34b9c4902e (diff) |
minor cleanup
Diffstat (limited to 'src')
-rw-r--r-- | src/libcmd/repl.cc | 2 | ||||
-rw-r--r-- | src/libexpr/eval.cc | 45 | ||||
-rw-r--r-- | src/libexpr/parser.y | 1 | ||||
-rw-r--r-- | src/libexpr/primops/fetchTree.cc | 15 |
4 files changed, 29 insertions, 34 deletions
diff --git a/src/libcmd/repl.cc b/src/libcmd/repl.cc index 22a6439b4..edd74c993 100644 --- a/src/libcmd/repl.cc +++ b/src/libcmd/repl.cc @@ -547,8 +547,6 @@ bool NixRepl::processLine(std::string line) loadDebugTraceEnv(*iter); break; } - // std::cout << "\n" << ANSI_BLUE << idx << ANSI_NORMAL << ": "; - // showDebugTrace(std::cout, *iter); } } else if (arg == "step") { diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index 7d02222cf..914739f70 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -789,6 +789,7 @@ void mapStaticEnvBindings(const StaticEnv &se, const Env &env, valmap & vm) auto map = valmap(); if (env.type == Env::HasWithAttrs) { + // add 'with' bindings. Bindings::iterator j = env.values[0]->attrs->begin(); while (j != env.values[0]->attrs->end()) { map[j->name] = j->value; @@ -1485,15 +1486,15 @@ void ExprSelect::eval(EvalState & state, Env & env, Value & v) try { auto dts = - debuggerHook ? - makeDebugTraceStacker( - state, - *this, - env, - *pos2, - "while evaluating the attribute '%1%'", - showAttrPath(state, env, attrPath)) - : nullptr; + debuggerHook ? + makeDebugTraceStacker( + state, + *this, + env, + *pos2, + "while evaluating the attribute '%1%'", + showAttrPath(state, env, attrPath)) + : nullptr; for (auto & i : attrPath) { state.nrLookups++; @@ -2082,13 +2083,13 @@ void EvalState::forceValueDeep(Value & v) try { auto dts = - debuggerHook ? - // if the value is a thunk, we're evaling. otherwise no trace necessary. - (i.value->isThunk() ? - makeDebugTraceStacker(*this, *v.thunk.expr, *v.thunk.env, *i.pos, - "while evaluating the attribute '%1%'", i.name) - : nullptr) - : nullptr; + debuggerHook ? + // if the value is a thunk, we're evaling. otherwise no trace necessary. + (i.value->isThunk() ? + makeDebugTraceStacker(*this, *v.thunk.expr, *v.thunk.env, *i.pos, + "while evaluating the attribute '%1%'", i.name) + : nullptr) + : nullptr; recurse(*i.value); } catch (Error & e) { @@ -2123,8 +2124,7 @@ NixFloat EvalState::forceFloat(Value & v, const Pos & pos) if (v.type() == nInt) return v.integer; else if (v.type() != nFloat) - throwTypeError(pos, "value is %1% while a float was expected", v, - *this); + throwTypeError(pos, "value is %1% while a float was expected", v, *this); return v.fpoint; } @@ -2133,8 +2133,7 @@ bool EvalState::forceBool(Value & v, const Pos & pos) { forceValue(v, pos); if (v.type() != nBool) - throwTypeError(pos, "value is %1% while a Boolean was expected", v, - *this); + throwTypeError(pos, "value is %1% while a Boolean was expected", v, *this); return v.boolean; } @@ -2149,8 +2148,7 @@ void EvalState::forceFunction(Value & v, const Pos & pos) { forceValue(v, pos); if (v.type() != nFunction && !isFunctor(v)) - throwTypeError(pos, "value is %1% while a function was expected", v, - *this); + throwTypeError(pos, "value is %1% while a function was expected", v, *this); } @@ -2158,8 +2156,7 @@ std::string_view EvalState::forceString(Value & v, const Pos & pos) { forceValue(v, pos); if (v.type() != nString) { - throwTypeError(pos, "value is %1% while a string was expected", v, - *this); + throwTypeError(pos, "value is %1% while a string was expected", v, *this); } return v.string.s; } diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y index ecfa5b7c2..1a5832e6b 100644 --- a/src/libexpr/parser.y +++ b/src/libexpr/parser.y @@ -23,7 +23,6 @@ #include "nixexpr.hh" #include "eval.hh" #include "globals.hh" -#include <iostream> namespace nix { diff --git a/src/libexpr/primops/fetchTree.cc b/src/libexpr/primops/fetchTree.cc index 131cc87dc..c7b73b83d 100644 --- a/src/libexpr/primops/fetchTree.cc +++ b/src/libexpr/primops/fetchTree.cc @@ -226,13 +226,14 @@ static void fetch(EvalState & state, const Pos & pos, Value * * args, Value & v, expectedHash = newHashAllowEmpty(state.forceStringNoCtx(*attr.value, *attr.pos), htSHA256); else if (n == "name") name = state.forceStringNoCtx(*attr.value, *attr.pos); - else { - auto e = EvalError({ - .msg = hintfmt("unsupported argument '%s' to '%s'", attr.name, who), - .errPos = *attr.pos - }); - state.debugLastTrace(e); - throw e; + else + { + auto e = EvalError({ + .msg = hintfmt("unsupported argument '%s' to '%s'", attr.name, who), + .errPos = *attr.pos + }); + state.debugLastTrace(e); + throw e; } } |