diff --git a/src/parser.cpp b/src/parser.cpp index 4a2718d..25146cc 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -655,7 +655,7 @@ namespace Solstice { if (isTemp(children[1].outputId)) codeBlock.toBeDropped.push_back(children[1].outputId); code.push_back(codeBlock); // Make sure we know what the variable type is - variables[children[0].outputId] = children[1].data.getTypeString(); + variables[children[0].outputId] = checkNodeReturnType(children[1]); break; } case SolNodeType::FunctionCall: { @@ -1268,7 +1268,7 @@ namespace Solstice { } case SolNodeType::BracketStart: { // function call - if (rootNode.children.back().nodeType == SolNodeType::Identifier) { + if (!rootNode.children.empty() && rootNode.children.back().nodeType == SolNodeType::Identifier) { SolNode fnCallNode(SolNodeType::FunctionCall); fnCallNode.line = tokenObj.line; fnCallNode.lineContent = tokenObj.lineContent; @@ -1317,8 +1317,9 @@ namespace Solstice { tokens.push_back(tokenopt.value()); } auto node = Parser(tokens).parse(); - node.nodeType = SolNodeType::Expression; - rootNode.addNode(node); + if (!node.children.empty()) { + rootNode.addNode(node.children.back()); + } } break; } diff --git a/src/parser.h b/src/parser.h index 1f0dae0..2ab65d3 100644 --- a/src/parser.h +++ b/src/parser.h @@ -35,7 +35,7 @@ std::string n2t = checkNodeReturnType(node2); \ if (n1t != n2t) { \ if (!(n1t == "int" && n2t == "double" || n1t == "double" && n2t == "int")) { \ - Error::typingError("Expected types to be the same for " + std::string(op), node1.line, node1.lineContent); \ + Error::typingError("Expected types to be the same for " + std::string(op) + " (got types '" + n1t + "' and '" + n2t + "')", node1.line, node1.lineContent); \ } \ } \ }