From 02df94a46a73fd29110a4515b3ad4bc6dc77bb8b Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Fri, 10 Feb 2023 14:53:51 +0100 Subject: [PATCH 1/2] Repair DSL Namespace values being constant broken in #9627 master before #9627 (a0286e9c6): <1> => namespace n { x = 42; x = 42 } ^^^^^^ Constant must not be modified. <2> => HEAD of #9627 (24b57f0d3): <1> => namespace n { x = 42; x = 42 } null <2> => --- lib/base/namespace.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/base/namespace.cpp b/lib/base/namespace.cpp index cb7c872bd..4c5f4f62a 100644 --- a/lib/base/namespace.cpp +++ b/lib/base/namespace.cpp @@ -58,7 +58,7 @@ void Namespace::Set(const String& field, const Value& value, bool isConst, const auto nsVal = m_Data.find(field); if (nsVal == m_Data.end()) { - m_Data[field] = NamespaceValue{value, isConst}; + m_Data[field] = NamespaceValue{value, isConst || m_ConstValues}; } else { if (nsVal->second.Const) { BOOST_THROW_EXCEPTION(ScriptError("Constant must not be modified.", debugInfo)); From 683095a1653f9bff6e284a68c3e60db9188f2b43 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Fri, 10 Feb 2023 15:47:25 +0100 Subject: [PATCH 2/2] Make globals.Internal values non-const by default That namespace is internal anyway. Previous commit, icinga2 console: Error: Constants must not be removed. This commit fixes it. --- lib/base/scriptframe.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/base/scriptframe.cpp b/lib/base/scriptframe.cpp index 7476f13e6..7a7f44c5f 100644 --- a/lib/base/scriptframe.cpp +++ b/lib/base/scriptframe.cpp @@ -36,7 +36,7 @@ INITIALIZE_ONCE_WITH_PRIORITY([]() { l_StatsNS = new Namespace(true); globalNS->Set("StatsFunctions", l_StatsNS, true); - globalNS->Set("Internal", new Namespace(true), true); + globalNS->Set("Internal", new Namespace(), true); }, InitializePriority::CreateNamespaces); INITIALIZE_ONCE_WITH_PRIORITY([]() {