add error prefix to the runtime exception message

This commit is contained in:
2020-02-03 22:28:37 +01:00
parent 02fb7b7cc2
commit 7c56f401ac

View File

@@ -25,9 +25,12 @@ public class GetFunctions extends KlangBaseVisitor<Void> {
@Override
public Void visitFunctionDef(KlangParser.FunctionDefContext ctx) {
String name = ctx.funcName.getText();
int line = ctx.start.getLine();
int col = ctx.start.getCharPositionInLine();
if (this.funcs.containsKey(name)) {
throw new Error("Function " + name + " defined multiple times");
String error = "Function " + name + " defined multiple times.";
throw new Error(Helper.getErrorPrefix(line, col) + error);
}
Type returnType = Type.getByName(ctx.returnType.type().getText());