From 220fc8622d030f06e286ffe06abef9f16102eba0 Mon Sep 17 00:00:00 2001 From: Arha Gatram Date: Thu, 25 Jun 2026 16:36:02 -0700 Subject: [PATCH] block: Fix incorrect policy scope creation order Creates the policy scope after the variable scope instead of the other way round. This ensures that the cmStateSnapshot which the policy is registered to is the same as the one created with the variable scope so that reading a policy from the parent snapshot does not incorrectly read policies from the new snapshot. --- Source/cmBlockCommand.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/cmBlockCommand.cxx b/Source/cmBlockCommand.cxx index 575efe646c..d57c17051a 100644 --- a/Source/cmBlockCommand.cxx +++ b/Source/cmBlockCommand.cxx @@ -40,19 +40,19 @@ public: BlockScopePushPop& operator=(BlockScopePushPop const&) = delete; private: - std::unique_ptr PolicyScope; std::unique_ptr VariableScope; + std::unique_ptr PolicyScope; std::unique_ptr DiagnosticScope; }; BlockScopePushPop::BlockScopePushPop(cmMakefile* mf, ScopeSet const& scopes) { - if (scopes.contains(ScopeType::POLICIES)) { - this->PolicyScope = cm::make_unique(mf); - } if (scopes.contains(ScopeType::VARIABLES)) { this->VariableScope = cm::make_unique(mf); } + if (scopes.contains(ScopeType::POLICIES)) { + this->PolicyScope = cm::make_unique(mf); + } if (scopes.contains(ScopeType::DIAGNOSTICS)) { this->DiagnosticScope = cm::make_unique(mf); }