mirror of
https://github.com/NixOS/nix
synced 2025-06-25 19:01:16 +02:00
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.
This commit is contained in:
parent
7f814d6d9a
commit
a385e51a08
18 changed files with 171 additions and 159 deletions
|
@ -308,7 +308,7 @@ static BoehmGCStackAllocator boehmGCStackAllocator;
|
|||
#endif
|
||||
|
||||
|
||||
static SymbolIdx getName(const AttrName & name, EvalState & state, Env & env)
|
||||
static Symbol getName(const AttrName & name, EvalState & state, Env & env)
|
||||
{
|
||||
if (name.symbol) {
|
||||
return name.symbol;
|
||||
|
@ -769,7 +769,7 @@ void EvalState::throwEvalError(const PosIdx pos, const char * s, const std::stri
|
|||
});
|
||||
}
|
||||
|
||||
void EvalState::throwEvalError(const PosIdx p1, const char * s, const SymbolIdx sym, const PosIdx p2) const
|
||||
void EvalState::throwEvalError(const PosIdx p1, const char * s, const Symbol sym, const PosIdx p2) const
|
||||
{
|
||||
// p1 is where the error occurred; p2 is a position mentioned in the message.
|
||||
throw EvalError({
|
||||
|
@ -787,7 +787,7 @@ void EvalState::throwTypeError(const PosIdx pos, const char * s) const
|
|||
}
|
||||
|
||||
void EvalState::throwTypeError(const PosIdx pos, const char * s, const ExprLambda & fun,
|
||||
const SymbolIdx s2) const
|
||||
const Symbol s2) const
|
||||
{
|
||||
throw TypeError({
|
||||
.msg = hintfmt(s, fun.showNamePos(*this), symbols[s2]),
|
||||
|
@ -796,7 +796,7 @@ void EvalState::throwTypeError(const PosIdx pos, const char * s, const ExprLambd
|
|||
}
|
||||
|
||||
void EvalState::throwTypeError(const PosIdx pos, const Suggestions & suggestions, const char * s,
|
||||
const ExprLambda & fun, const SymbolIdx s2) const
|
||||
const ExprLambda & fun, const Symbol s2) const
|
||||
{
|
||||
throw TypeError(ErrorInfo {
|
||||
.msg = hintfmt(s, fun.showNamePos(*this), symbols[s2]),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue