diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index e6314f63e..39f1a625f 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -934,7 +934,7 @@ void EvalState::mkThunk_(Value & v, Expr * expr) void EvalState::mkPos(Value & v, PosIdx p) { auto pos = positions[p]; - if (pos.file.set()) { + if (!pos.file.empty()) { auto attrs = buildBindings(3); attrs.alloc(sFile).mkString(pos.file); attrs.alloc(sLine).mkInt(pos.line); @@ -1296,7 +1296,7 @@ void ExprSelect::eval(EvalState & state, Env & env, Value & v) } catch (Error & e) { auto pos2r = state.positions[pos2]; - if (pos2 && pos2r.file != state.sDerivationNix) + if (pos2 && pos2r.file != state.derivationNixPath) state.addErrorTrace(e, pos2, "while evaluating the attribute '%1%'", showAttrPath(state, env, attrPath)); throw; diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh index b05e8d5d0..71d6e7e7f 100644 --- a/src/libexpr/eval.hh +++ b/src/libexpr/eval.hh @@ -75,6 +75,8 @@ public: SymbolTable symbols; PosTable positions; + static inline std::string derivationNixPath = "//builtin/derivation.nix"; + const Symbol sWith, sOutPath, sDrvPath, sType, sMeta, sName, sValue, sSystem, sOverrides, sOutputs, sOutputName, sIgnoreNulls, sFile, sLine, sColumn, sFunctor, sToString, diff --git a/src/libexpr/nixexpr.hh b/src/libexpr/nixexpr.hh index d9392cff5..2e12f0b4f 100644 --- a/src/libexpr/nixexpr.hh +++ b/src/libexpr/nixexpr.hh @@ -26,7 +26,7 @@ MakeError(RestrictedPathError, Error); struct Pos { - Symbol file; + std::string file; FileOrigin origin; uint32_t line; uint32_t column; @@ -64,10 +64,10 @@ public: explicit Origin(uint32_t idx): idx(idx), file{}, origin{} {} public: - const Symbol file; + const std::string file; const FileOrigin origin; - Origin(Symbol file, FileOrigin origin): file(file), origin(origin) {} + Origin(std::string file, FileOrigin origin): file(std::move(file)), origin(origin) {} }; struct Offset { diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y index 0052a8070..1f950a057 100644 --- a/src/libexpr/parser.y +++ b/src/libexpr/parser.y @@ -648,14 +648,14 @@ Expr * EvalState::parse(char * text, size_t length, FileOrigin origin, const PathView path, const PathView basePath, StaticEnv & staticEnv) { yyscan_t scanner; - Symbol file; + std::string file; switch (origin) { case foFile: - file = symbols.create(path); + file = path; break; case foStdin: case foString: - file = symbols.create(text); + file = text; break; default: assert(false); diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc index 9cdcfd0b9..81fb5acfb 100644 --- a/src/libexpr/primops.cc +++ b/src/libexpr/primops.cc @@ -3915,7 +3915,7 @@ void EvalState::createBaseEnv() /* Add a wrapper around the derivation primop that computes the `drvPath' and `outPath' attributes lazily. */ - sDerivationNix = symbols.create("//builtin/derivation.nix"); + sDerivationNix = symbols.create(derivationNixPath); auto vDerivation = allocValue(); addConstant("derivation", vDerivation); diff --git a/src/libutil/error.hh b/src/libutil/error.hh index 348018f57..f4706e3ed 100644 --- a/src/libutil/error.hh +++ b/src/libutil/error.hh @@ -87,11 +87,7 @@ struct ErrPos { origin = pos.origin; line = pos.line; column = pos.column; - // is file symbol null? - if (pos.file.set()) - file = pos.file; - else - file = ""; + file = pos.file; return *this; }