diff --git a/lix/libexpr/eval.cc b/lix/libexpr/eval.cc index befaabf4e..55d6f37de 100644 --- a/lix/libexpr/eval.cc +++ b/lix/libexpr/eval.cc @@ -862,7 +862,7 @@ void EvalState::mkPos(Value & v, PosIdx p) std::tie(line, col) = makePositionThunks(*this, p); v = {NewValueAs::attrs, attrs}; } else - v.mkNull(); + v = Value::VNULL; } Value EvalPaths::mkStorePathString(const StorePath & p) diff --git a/lix/libexpr/json-to-value.cc b/lix/libexpr/json-to-value.cc index 00cea5b5b..603271a30 100644 --- a/lix/libexpr/json-to-value.cc +++ b/lix/libexpr/json-to-value.cc @@ -94,7 +94,7 @@ public: bool null() override { - rs->value().mkNull(); + rs->value() = Value::VNULL; rs->add(); return true; } diff --git a/lix/libexpr/primops.cc b/lix/libexpr/primops.cc index 4e4546962..6e0afe1d0 100644 --- a/lix/libexpr/primops.cc +++ b/lix/libexpr/primops.cc @@ -1899,7 +1899,7 @@ static void prim_unsafeGetAttrPos(EvalState & state, Value * * args, Value & v) state.forceAttrs(*args[1], noPos, "while evaluating the second argument passed to builtins.unsafeGetAttrPos"); auto i = args[1]->attrs()->get(state.ctx.symbols.create(attr)); if (!i) { - v.mkNull(); + v = Value::VNULL; } else { state.mkPos(v, i->pos); } @@ -2853,7 +2853,7 @@ void prim_match(EvalState & state, Value * * args, Value & v) std::cmatch match; if (!std::regex_match(str.begin(), str.end(), match, regex)) { - v.mkNull(); + v = Value::VNULL; return; } @@ -2863,7 +2863,7 @@ void prim_match(EvalState & state, Value * * args, Value & v) v = {NewValueAs::list, result}; for (size_t i = 0; i < len; ++i) { if (!match[i+1].matched) - result->elems[i].mkNull(); + result->elems[i] = Value::VNULL; else result->elems[i] = {NewValueAs::string, match[i + 1].str()}; } @@ -2916,7 +2916,7 @@ void prim_split(EvalState & state, Value * * args, Value & v) elem = {NewValueAs::list, content}; for (size_t si = 0; si < slen; ++si) { if (!match[si + 1].matched) - content->elems[si].mkNull(); + content->elems[si] = Value::VNULL; else content->elems[si] = {NewValueAs::string, match[si + 1].str()}; } diff --git a/lix/libexpr/primops/fromTOML.cc b/lix/libexpr/primops/fromTOML.cc index 28174c8b3..b59c807ea 100644 --- a/lix/libexpr/primops/fromTOML.cc +++ b/lix/libexpr/primops/fromTOML.cc @@ -57,7 +57,7 @@ void prim_fromTOML(EvalState & state, Value ** args, Value & val) throw std::runtime_error("Dates and times are not supported"); break; case toml::value_t::empty: - v.mkNull(); + v = Value::VNULL; break; } }; diff --git a/lix/libexpr/value.hh b/lix/libexpr/value.hh index e6257a4fe..84ff65b65 100644 --- a/lix/libexpr/value.hh +++ b/lix/libexpr/value.hh @@ -766,11 +766,6 @@ public: */ inline ValueType type(bool invalidIsThunk = false) const; - inline void mkNull() - { - *this = {NewValueAs::null}; - } - bool isList() const { return internalType() == tList; diff --git a/tests/functional/plugins/plugintest.cc b/tests/functional/plugins/plugintest.cc index ba37414e5..b3dc09862 100644 --- a/tests/functional/plugins/plugintest.cc +++ b/tests/functional/plugins/plugintest.cc @@ -29,7 +29,7 @@ static void prim_anotherNull (EvalState & state, Value ** args, Value & v) { assert(entryCalled); if (mySettings.settingSet) - v.mkNull(); + v = Value::VNULL; else v = {NewValueAs::boolean, false}; } diff --git a/tests/unit/libexpr/json.cc b/tests/unit/libexpr/json.cc index a0e704042..c5eccb1fb 100644 --- a/tests/unit/libexpr/json.cc +++ b/tests/unit/libexpr/json.cc @@ -15,8 +15,7 @@ namespace nix { }; TEST_F(JSONValueTest, null) { - Value v; - v.mkNull(); + Value v = Value::VNULL; ASSERT_EQ(getJSONValue(v), "null"); } diff --git a/tests/unit/libexpr/value/print.cc b/tests/unit/libexpr/value/print.cc index 0f6b01fea..eefe76219 100644 --- a/tests/unit/libexpr/value/print.cc +++ b/tests/unit/libexpr/value/print.cc @@ -48,8 +48,7 @@ TEST_F(ValuePrintingTests, tPath) TEST_F(ValuePrintingTests, tNull) { - Value vNull; - vNull.mkNull(); + Value vNull = Value::VNULL; test(vNull, "null"); } @@ -95,7 +94,7 @@ TEST_F(ValuePrintingTests, vThunk) TEST_F(ValuePrintingTests, vApp) { EvalMemory mem; - Value vFn{NewValueAs::null}; + Value vFn = Value::VNULL; Value vApp{NewValueAs::app, mem, vFn, vFn}; test(vApp, "«thunk»"); @@ -368,8 +367,7 @@ TEST_F(ValuePrintingTests, ansiColorsPath) TEST_F(ValuePrintingTests, ansiColorsNull) { - Value v; - v.mkNull(); + Value v = Value::VNULL; test(v, ANSI_CYAN "null" ANSI_NORMAL,