fixed wrong exception type
This commit is contained in:
parent
dbb61e2a81
commit
920fa2fa48
@ -22,11 +22,10 @@ public class Compiler {
|
|||||||
|
|
||||||
if (args.length < 1) {
|
if (args.length < 1) {
|
||||||
System.out.println("Usage: java -jar Compiler.jar <file_path> [--suppress-details]");
|
System.out.println("Usage: java -jar Compiler.jar <file_path> [--suppress-details]");
|
||||||
// return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//String filePath = args[0];
|
String filePath = args[0];
|
||||||
String filePath = "C:/Users/dh10krj/Downloads/TestClass.java";
|
|
||||||
|
|
||||||
boolean suppressDetails = false;
|
boolean suppressDetails = false;
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ public class WhileStatement extends AbstractType implements IStatement {
|
|||||||
// check condition
|
// check condition
|
||||||
TypeCheckResult conditionType = condition.typeCheck(methodContext, typeContext, localVars);
|
TypeCheckResult conditionType = condition.typeCheck(methodContext, typeContext, localVars);
|
||||||
if (!conditionType.type.equals("boolean")) {
|
if (!conditionType.type.equals("boolean")) {
|
||||||
throw new IllegalArgumentException("Expected boolean");
|
throw new TypeCheckException("Condition of while-statement is of type " + conditionType.type + " but should be boolean.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// check code block
|
// check code block
|
||||||
|
Loading…
Reference in New Issue
Block a user