diff --git a/src/main/java/TestClass.java b/src/main/java/TestClass.java index 827e3c9..375caa8 100644 --- a/src/main/java/TestClass.java +++ b/src/main/java/TestClass.java @@ -13,6 +13,10 @@ class TestClass { Example m1(int n){ return new Example(); } + public static void main(String[] args){ + TestClass t2 = new TestClass(); + t2.meth(2); + } } class Example { diff --git a/src/main/java/abstractSyntaxTree/Statement/BlockStatement.java b/src/main/java/abstractSyntaxTree/Statement/BlockStatement.java index 34d4122..5f748b7 100644 --- a/src/main/java/abstractSyntaxTree/Statement/BlockStatement.java +++ b/src/main/java/abstractSyntaxTree/Statement/BlockStatement.java @@ -65,6 +65,9 @@ public class BlockStatement extends AbstractType implements IStatement { } TypeCheckResult typeOfCurrentStatement = statement.typeCheck(methodContext, typeContext, localVars); + if(statement instanceof MethodCallStatementExpression methodCall){ + typeOfCurrentStatement.type = "void"; + } if(statement instanceof LocalVarDecl localVarDecl){ localVars.put(localVarDecl.identifier, localVarDecl.type); } @@ -106,6 +109,7 @@ public class BlockStatement extends AbstractType implements IStatement { } if(this.returnType == null) this.returnType = "void"; + result.type = this.returnType; setTypeCheckResult(result); return result;