added type comparison in assign

This commit is contained in:
Felix Müller 2024-06-09 00:37:24 +02:00
parent c4e803fc23
commit aeeec168a3
1 changed files with 15 additions and 0 deletions

View File

@ -1418,6 +1418,21 @@ bool compareTypes(Type * leftType, Type * rightType) {
return SEMANTIC_ERROR; return SEMANTIC_ERROR;
} }
Type* varType = NULL;
if(assign.variable->kind == VariableKindDeclaration) {
varType = assign.variable->impl.declaration.type;
}else if(assign.variable->kind == VariableKindDefinition) {
varType = assign.variable->impl.definiton.declaration.type;
}
bool result =compareTypes(varType, assign.value->result);
if(result ==FALSE ) {
return SEMANTIC_ERROR;
}
ParentStatement->impl.assignment = assign; ParentStatement->impl.assignment = assign;
return SEMANTIC_OK; return SEMANTIC_OK;
} }