added type comparison in assign
This commit is contained in:
parent
c4e803fc23
commit
aeeec168a3
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue