25- Strict check between function signature and function call
This commit is contained in:
@@ -697,10 +697,8 @@ public class ContextAnalysis extends KlangBaseVisitor<Node> {
|
|||||||
Expression[] args = new Expression[argCount];
|
Expression[] args = new Expression[argCount];
|
||||||
for (int i = 0; i < argCount; i++) {
|
for (int i = 0; i < argCount; i++) {
|
||||||
Expression expression = (Expression) this.visit(ctx.functionCall().arguments().expression(i));
|
Expression expression = (Expression) this.visit(ctx.functionCall().arguments().expression(i));
|
||||||
try {
|
if (!expression.type.equals(func.signature[i])) {
|
||||||
expression.type.combine(func.signature[i]); // Make sure the types are matching
|
throw new RuntimeException(Helper.getErrorPrefix(line, col) + "argument " + i + " Expected " + func.signature[i].getName() + " but got: " + expression.type.getName());
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException(Helper.getErrorPrefix(line, col) + "argument " + i + " " + e.getMessage());
|
|
||||||
}
|
}
|
||||||
args[i] = expression;
|
args[i] = expression;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user