method call without using return is a void statement
This commit is contained in:
parent
94b3830561
commit
47a8d50185
@ -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 {
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user