25- Strict check between function signature and function call

This commit is contained in:
Marvin Kaiser
2020-03-04 20:53:50 +01:00
parent 18cfbdcbb5
commit 229920946d

View File

@@ -697,10 +697,8 @@ public class ContextAnalysis extends KlangBaseVisitor<Node> {
Expression[] args = new Expression[argCount];
for (int i = 0; i < argCount; i++) {
Expression expression = (Expression) this.visit(ctx.functionCall().arguments().expression(i));
try {
expression.type.combine(func.signature[i]); // Make sure the types are matching
} catch (Exception e) {
throw new RuntimeException(Helper.getErrorPrefix(line, col) + "argument " + i + " " + e.getMessage());
if (!expression.type.equals(func.signature[i])) {
throw new RuntimeException(Helper.getErrorPrefix(line, col) + "argument " + i + " Expected " + func.signature[i].getName() + " but got: " + expression.type.getName());
}
args[i] = expression;
}