diff --git a/src/parser/parser.c b/src/parser/parser.c index 76023f7..8e06530 100644 --- a/src/parser/parser.c +++ b/src/parser/parser.c @@ -1076,7 +1076,10 @@ static inline ResultType(Nothing, charptr) parseWhile(SolsParser* parser) { // Last child of parent is code block, we need to move it SolsNode codeBlock = parser->currentParent->children.at[parser->currentParent->children.count - 1]; parser->currentParent->children.count--; - addChildToSolsNode(&node.as.success, codeBlock); + + // We need to get the actual node from the parent to modify it + SolsNode* whileNode = &parser->currentParent->children.at[parser->currentParent->children.count - 1]; + addChildToSolsNode(whileNode, codeBlock); return Success(Nothing, charptr, {}); @@ -1138,7 +1141,10 @@ static inline ResultType(Nothing, charptr) parseIf(SolsParser* parser) { // Last child of parent is code block, we need to move it SolsNode codeBlock = parser->currentParent->children.at[parser->currentParent->children.count - 1]; parser->currentParent->children.count--; - addChildToSolsNode(&node.as.success, codeBlock); + + // We need to get the actual node from the parent to modify it + SolsNode* ifNode = &parser->currentParent->children.at[parser->currentParent->children.count - 1]; + addChildToSolsNode(ifNode, codeBlock); return Success(Nothing, charptr, {}); @@ -1414,7 +1420,9 @@ static inline ResultType(Nothing, charptr) parseDef(SolsParser* parser) { SolsNode codeBlock = parser->currentParent->children.at[parser->currentParent->children.count - 1]; parser->currentParent->children.count--; - addChildToSolsNode(&parser->currentParent->children.at[0], parser->currentParent->children.at[1]); + // We need to get the actual node from the parent to modify it + SolsNode* defNode = &parser->currentParent->children.at[parser->currentParent->children.count - 1]; + addChildToSolsNode(defNode, codeBlock); return Success(Nothing, charptr, {}); }