aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/primops.cc
diff options
context:
space:
mode:
authorpennae <github@quasiparticle.net>2022-04-22 21:45:39 +0200
committerpennae <github@quasiparticle.net>2022-04-25 15:37:01 +0200
commita385e51a086006c0f7d7c4bc6ed910dbe5375c4d (patch)
tree2b9776ddd7fa0977827e21379cd138cc54943071 /src/libexpr/primops.cc
parent7f814d6d9af9d78f922d59115a94078f807676a8 (diff)
rename SymbolIdx -> Symbol, Symbol -> SymbolStr
after #6218 `Symbol` no longer confers a uniqueness invariant on the string it wraps, it is now possible to create multiple symbols that compare equal but whose string contents have different addresses. this guarantee is now only provided by `SymbolIdx`, leaving `Symbol` only as a string wrapper that knows about the intricacies of how symbols need to be formatted for output. this change renames `SymbolIdx` to `Symbol` to restore the previous semantics of `Symbol` to that name. we also keep the wrapper type and rename it to `SymbolStr` instead of returning plain strings from lookups into the symbol table because symbols are formatted for output in many places. theoretically we do not need `SymbolStr`, only a function that formats a string for output as a symbol, but having to wrap every symbol that appears in a message into eg `formatSymbol()` is error-prone and inconvient.
Diffstat (limited to 'src/libexpr/primops.cc')
-rw-r--r--src/libexpr/primops.cc8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc
index 36a67a39d..40e9f7091 100644
--- a/src/libexpr/primops.cc
+++ b/src/libexpr/primops.cc
@@ -584,7 +584,7 @@ typedef std::list<Value *> ValueList;
static Bindings::iterator getAttr(
EvalState & state,
std::string_view funcName,
- SymbolIdx attrSym,
+ Symbol attrSym,
Bindings * attrSet,
const PosIdx pos)
{
@@ -2047,7 +2047,7 @@ static void prim_path(EvalState & state, const PosIdx pos, Value * * args, Value
PathSet context;
for (auto & attr : *args[0]->attrs) {
- auto & n(state.symbols[attr.name]);
+ auto n = state.symbols[attr.name];
if (n == "path")
path = state.coerceToPath(attr.pos, *attr.value, context);
else if (attr.name == state.sName)
@@ -2314,7 +2314,7 @@ static void prim_listToAttrs(EvalState & state, const PosIdx pos, Value * * args
auto attrs = state.buildBindings(args[0]->listSize());
- std::set<SymbolIdx> seen;
+ std::set<Symbol> seen;
for (auto v2 : args[0]->listItems()) {
state.forceAttrs(*v2, pos);
@@ -2517,7 +2517,7 @@ static void prim_zipAttrsWith(EvalState & state, const PosIdx pos, Value * * arg
// attribute with the merge function application. this way we need not
// use (slightly slower) temporary storage the GC does not know about.
- std::map<SymbolIdx, std::pair<size_t, Value * *>> attrsSeen;
+ std::map<Symbol, std::pair<size_t, Value * *>> attrsSeen;
state.forceFunction(*args[0], pos);
state.forceList(*args[1], pos);