From fa161e9a380c530363c3eb72c9917e4db88287e0 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Mon, 13 Jul 2020 21:20:52 +0100 Subject: 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 Tested-by: BuildkiteCI --- third_party/nix/src/libexpr/parser.y | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'third_party/nix/src/libexpr/parser.y') diff --git a/third_party/nix/src/libexpr/parser.y b/third_party/nix/src/libexpr/parser.y index eb3f92db7844..2ea84fea66b9 100644 --- a/third_party/nix/src/libexpr/parser.y +++ b/third_party/nix/src/libexpr/parser.y @@ -16,6 +16,7 @@ #ifndef BISON_HEADER #define BISON_HEADER +#include #include #include "libutil/util.hh" #include "libexpr/nixexpr.hh" @@ -28,9 +29,9 @@ namespace nix { { EvalState & state; SymbolTable & symbols; - Expr * result; + Expr* result; Path basePath; - Symbol path; + std::optional path; std::string error; Symbol sLetBody; ParseData(EvalState & state) @@ -139,7 +140,6 @@ static void addAttr(ExprAttrs * attrs, AttrPath & attrPath, } else { // This attr path is not defined. Let's create it. attrs->attrs[*sym] = ExprAttrs::AttrDef(e, pos); - e->setName(*sym); } } else { // Same caveat as the identical line above. @@ -502,8 +502,9 @@ attrpath if (str) { $$->push_back(AttrName(str->s)); delete str; - } else + } else { $$->push_back(AttrName($3)); + } } | attr { $$ = new std::vector; $$->push_back(AttrName(data->symbols.Create($1))); } | string_attr -- cgit 1.4.1