fixed if Check
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Has been cancelled

This commit is contained in:
Bruder John 2024-07-04 10:40:13 +02:00
parent c0e197e2d0
commit 34bb86c7f4
3 changed files with 27 additions and 2 deletions

View File

@ -316,11 +316,15 @@ public class SemanticAnalyzer implements SemanticVisitor {
@Override @Override
public TypeCheckResult analyze(IfElseNode toCheck) { public TypeCheckResult analyze(IfElseNode toCheck) {
var resultIf = toCheck.ifStatement.accept(this); var resultIf = toCheck.ifStatement.accept(this);
if(toCheck.elseStatement != null){
var resultElse = toCheck.elseStatement.accept(this); var resultElse = toCheck.elseStatement.accept(this);
return new TypeCheckResult(resultIf.isValid() && resultElse.isValid(), new BaseType(TypeEnum.VOID)); return new TypeCheckResult(resultIf.isValid() && resultElse.isValid(), new BaseType(TypeEnum.VOID));
} }
return new TypeCheckResult(resultIf.isValid(), new BaseType(TypeEnum.VOID));
}
@Override @Override
public TypeCheckResult analyze(MethodCallNode toCheck) { public TypeCheckResult analyze(MethodCallNode toCheck) {

View File

@ -338,6 +338,17 @@ public class EndToTypedAstTest {
} }
@Test
public void Expression(){
ASTNode tast = SemanticHelper.generateTypedASTFrom("src/test/resources/input/singleFeatureSemanticTests/Expression.java");
SemanticAnalyzer.generateTast(tast);
assertTrue(SemanticAnalyzer.errors.isEmpty());
}
// ------------------ Helpers ------------------ // ------------------ Helpers ------------------
/** /**

View File

@ -0,0 +1,10 @@
class VariableCompare{
void trueMethod(boolean a, int c) {
if(a && c == 10){
}
}
}