diff --git a/src/main/java/semantic/SemanticAnalyzer.java b/src/main/java/semantic/SemanticAnalyzer.java index 8a16b47..c409c0d 100644 --- a/src/main/java/semantic/SemanticAnalyzer.java +++ b/src/main/java/semantic/SemanticAnalyzer.java @@ -181,8 +181,13 @@ public class SemanticAnalyzer implements SemanticVisitor { @Override public TypeCheckResult analyze(ReturnStatementNode toCheck) { - var result = toCheck.expression.accept(this); - return new TypeCheckResult(true, result.getType()); + if(toCheck.expression != null){ + var result = toCheck.expression.accept(this); + return new TypeCheckResult(true, result.getType()); + } else { + return new TypeCheckResult(false, null); + } + } @Override