fixed wrong exception type

This commit is contained in:
Krauß, Josefine 2024-07-04 11:10:14 +02:00
parent dbb61e2a81
commit 920fa2fa48
2 changed files with 3 additions and 4 deletions

View File

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

View File

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