From b287deb1f12491c4024207a391785bdf8cc94ff6 Mon Sep 17 00:00:00 2001 From: howsohazard <143410553+howsohazard@users.noreply.github.com> Date: Mon, 2 Dec 2024 16:25:54 -0500 Subject: [PATCH] 22346: Fixes issue when changing an opcode's type to an assoc where keys would be lost and turned into empty strings (#317) --- src/Amalgam/evaluablenode/EvaluableNode.cpp | 7 ++----- src/Amalgam/evaluablenode/EvaluableNodeTreeFunctions.cpp | 1 - 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Amalgam/evaluablenode/EvaluableNode.cpp b/src/Amalgam/evaluablenode/EvaluableNode.cpp index b3c5256f0..2bef58ab8 100644 --- a/src/Amalgam/evaluablenode/EvaluableNode.cpp +++ b/src/Amalgam/evaluablenode/EvaluableNode.cpp @@ -660,14 +660,11 @@ void EvaluableNode::SetType(EvaluableNodeType new_type, EvaluableNodeManager *en new_ordered.reserve(2 * mcn.size()); for(auto &[cn_id, cn] : mcn) { - //keep the reference from when it was an assoc - new_ordered.push_back(enm->AllocNodeWithReferenceHandoff(ENT_STRING, cn_id)); + EvaluableNode *key = Parser::ParseFromKeyStringId(cn_id, enm); + new_ordered.push_back(key); new_ordered.push_back(cn); } - //clear the mapped nodes here, because don't want to free the references - // as they were handed off to the newly allocated ordered child nodes - mcn.clear(); InitOrderedChildNodes(); //swap for efficiency swap(GetOrderedChildNodesReference(), new_ordered); diff --git a/src/Amalgam/evaluablenode/EvaluableNodeTreeFunctions.cpp b/src/Amalgam/evaluablenode/EvaluableNodeTreeFunctions.cpp index 0af5b2d9b..f1d68b5bc 100644 --- a/src/Amalgam/evaluablenode/EvaluableNodeTreeFunctions.cpp +++ b/src/Amalgam/evaluablenode/EvaluableNodeTreeFunctions.cpp @@ -243,7 +243,6 @@ EvaluableNode *GetTraversalPathListFromAToB(EvaluableNodeManager *enm, Evaluable && b_ancestor != a //stop if it's the target && nodes_visited.insert(b_ancestor_parent).second == true) //make sure not visited yet { - //find where the node matches if(b_ancestor_parent->IsAssociativeArray()) {