refactor(3p/nix/libexpr): Remove the nix::Symbol default constructor
Having a default constructor for this causes a variety of annoying situations across the codebase in which this is initialised to an unexpected value, leading to constant guarding against those conditions. It turns out there's actually no intrinsic reason that this default constructor needs to exist. The biggest one was addressed in CL/1138 and this commit cleans up the remaining bits. Change-Id: I4a847f50bc90e72f028598196592a7d8730a4e01 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1139 Reviewed-by: isomer <isomer@tvl.fyi> Tested-by: BuildkiteCI
This commit is contained in:
parent
afd1367337
commit
fa161e9a38
10 changed files with 50 additions and 37 deletions
15
third_party/nix/src/libexpr/nixexpr.cc
vendored
15
third_party/nix/src/libexpr/nixexpr.cc
vendored
|
|
@ -187,11 +187,11 @@ void ExprConcatStrings::show(std::ostream& str) const {
|
|||
void ExprPos::show(std::ostream& str) const { str << "__curPos"; }
|
||||
|
||||
std::ostream& operator<<(std::ostream& str, const Pos& pos) {
|
||||
if (!pos) {
|
||||
if (!pos || !pos.file.has_value()) {
|
||||
str << "undefined position";
|
||||
} else {
|
||||
str << (format(ANSI_BOLD "%1%" ANSI_NORMAL ":%2%:%3%") %
|
||||
(std::string)pos.file % pos.line % pos.column)
|
||||
(std::string)pos.file.value() % pos.line % pos.column)
|
||||
.str();
|
||||
}
|
||||
return str;
|
||||
|
|
@ -401,17 +401,12 @@ void ExprConcatStrings::bindVars(const StaticEnv& env) {
|
|||
void ExprPos::bindVars(const StaticEnv& env) {}
|
||||
|
||||
/* Storing function names. */
|
||||
|
||||
void Expr::setName(Symbol& name) {}
|
||||
|
||||
void ExprLambda::setName(Symbol& name) {
|
||||
this->name = name;
|
||||
body->setName(name);
|
||||
}
|
||||
void ExprLambda::setName(Symbol& name) { this->name = name; }
|
||||
|
||||
std::string ExprLambda::showNamePos() const {
|
||||
return (format("%1% at %2%") %
|
||||
(name.set() ? "'" + (std::string)name + "'" : "anonymous function") %
|
||||
(name.has_value() ? "'" + (std::string)name.value() + "'"
|
||||
: "anonymous function") %
|
||||
pos)
|
||||
.str();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue