From 2322d161e66dbee7246132f5582d5fd01566a608 Mon Sep 17 00:00:00 2001 From: ahmad Date: Sun, 12 May 2024 14:55:03 +0200 Subject: [PATCH] Update the typeCheck of TypedBlock --- .../de/maishai/typedast/typedclass/TypedBlock.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/de/maishai/typedast/typedclass/TypedBlock.java b/src/main/java/de/maishai/typedast/typedclass/TypedBlock.java index d1e3449..532c449 100644 --- a/src/main/java/de/maishai/typedast/typedclass/TypedBlock.java +++ b/src/main/java/de/maishai/typedast/typedclass/TypedBlock.java @@ -98,18 +98,24 @@ public class TypedBlock implements TypedNode { } } this.typeCheck(clas); + System.out.println("TypedBlock: " + this.toString()); } @Override public Type typeCheck(TypedClass clas) { - + Type chekType = null; for (TypedStatement stmt : stmts) { stmt.typeCheck(clas); + if(stmt instanceof TypedReturn returnStmt) { + chekType = returnStmt.getType(); + } } - //TODO: Type von Return zurückgeben - type = Type.VOID; + if(chekType == null) { + chekType = Type.VOID; + } + type = chekType; return type; }