diff --git a/lix/libexpr/eval.cc b/lix/libexpr/eval.cc index 202273202..84ed1130a 100644 --- a/lix/libexpr/eval.cc +++ b/lix/libexpr/eval.cc @@ -108,6 +108,7 @@ std::string showType(const Value & v) case Value::Acb::tExternal: return v.external()->showType(); case Value::Acb::tFloat: + case Value::Acb::tNull: return std::string(showType(v.type())); } #pragma GCC diagnostic pop diff --git a/lix/libexpr/value.cc b/lix/libexpr/value.cc index e8835808e..9c95a3c5d 100644 --- a/lix/libexpr/value.cc +++ b/lix/libexpr/value.cc @@ -12,6 +12,8 @@ namespace nix static const Value::List emptyListData{.size = 0}; Value Value::EMPTY_LIST{Value::list_t{}, &emptyListData}; +const Value::Null Value::NULL_ACB = {{Value::Acb::tNull}}; + static void copyContextToValue(Value::String & s, const NixStringContext & context) { if (!context.empty()) { diff --git a/lix/libexpr/value.hh b/lix/libexpr/value.hh index 7bccb785b..50a9b7b11 100644 --- a/lix/libexpr/value.hh +++ b/lix/libexpr/value.hh @@ -26,7 +26,6 @@ typedef enum { tInt = 1, tBool, tString, - tNull, tAttrs, tList, tThunk, @@ -214,6 +213,9 @@ public: struct String; struct Acb; + struct Null; + + static const Null NULL_ACB; // Discount `using NewValueAs::*;` // NOLINTNEXTLINE(bugprone-macro-parentheses) @@ -416,10 +418,7 @@ public: } /// Constructs a nix language value of the singleton type "null". - Value(null_t) - : internalType(tNull) - , _empty{0, 0} - { } + Value(null_t) : Value(NULL_ACB) {} /// Constructs a nix language value of type "set", with the attribute /// bindings pointed to by @ref bindings. @@ -640,6 +639,7 @@ public: enum { tExternal, tFloat, + tNull, } type; }; struct External : Acb @@ -650,6 +650,8 @@ public: { NixFloat value; }; + struct Null : Acb + {}; union { @@ -710,7 +712,6 @@ public: case tBool: return nBool; case tString: return _string->isPath() ? nPath : nString; - case tNull: return nNull; case tAttrs: return nAttrs; case tList: return nList; @@ -723,6 +724,8 @@ public: return nExternal; case Acb::tFloat: return nFloat; + case Acb::tNull: + return nNull; } case tThunk: return nThunk; @@ -790,8 +793,7 @@ public: inline void mkNull() { - clearValue(); - internalType = tNull; + *this = {NewValueAs::null}; } inline void mkAttrs(Bindings * a)