Fixe Type Error
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run

This commit is contained in:
i22035 2024-07-04 20:23:43 +02:00
parent c315966219
commit 1de6add080
8 changed files with 8 additions and 25 deletions

View File

@ -14,7 +14,6 @@ public class ConstructorNode extends MethodNode implements Visitable {
public AccessModifierNode accessType; public AccessModifierNode accessType;
public String identifier; public String identifier;
public List<ParameterNode> parameters = new ArrayList<>(); public List<ParameterNode> parameters = new ArrayList<>();
public BlockNode block;
public ConstructorNode(String accessType, String identifier, BlockNode block) { public ConstructorNode(String accessType, String identifier, BlockNode block) {
this.accessType = new AccessModifierNode(accessType); this.accessType = new AccessModifierNode(accessType);

View File

@ -114,10 +114,6 @@ public class SemanticAnalyzer implements SemanticVisitor {
@Override @Override
public TypeCheckResult analyze(MethodNode methodNode) { public TypeCheckResult analyze(MethodNode methodNode) {
if (methodNode instanceof ConstructorNode) {
return new TypeCheckResult(true, new BaseType(TypeEnum.VOID));
} else {
var valid = true; var valid = true;
for (var otherMethod : currentClass.getMethods()) { for (var otherMethod : currentClass.getMethods()) {
@ -159,8 +155,6 @@ public class SemanticAnalyzer implements SemanticVisitor {
} }
return new TypeCheckResult(valid, resultType); return new TypeCheckResult(valid, resultType);
}
} }
@Override @Override
@ -177,8 +171,6 @@ public class SemanticAnalyzer implements SemanticVisitor {
currentFields.put(toCheck.identifier, toCheck.type); currentFields.put(toCheck.identifier, toCheck.type);
} }
return new TypeCheckResult(true, null); return new TypeCheckResult(true, null);
} }
@Override @Override

View File

@ -1,8 +1,8 @@
class Null{ class Null{
Null a; int a;
public Null(){ public Null(){
this.a = null; this.a = 1;
} }
} }

View File

@ -1,16 +1,8 @@
public class Compiler { public class If {
Node node; public If() {
public int add(int i, int j) { int intValue = 5;
node = new Node(); if(intValue == 5) {
node.x = 1; intValue--;
return i+j; }
}
}
public class Node {
public int x;
public void main() {
Compiler compiler = new Compiler();
int i = compiler.add(5, 8);
} }
} }