Function calling fix

This commit is contained in:
2026-01-12 14:45:07 +11:00
parent ca8db171d9
commit c5b67bff72
2 changed files with 6 additions and 5 deletions

View File

@@ -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;
}

View File

@@ -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); \
} \
} \
}