part of type_check_visitor

This commit is contained in:
ProgramSnail 2023-05-04 16:11:25 +03:00
parent 94ef8702fb
commit f7e985a448
10 changed files with 377 additions and 88 deletions

View file

@ -53,6 +53,16 @@ void LinkSymbolsVisitor::Visit(TypeExpression* node) { // TODO: check
error_handling::HandleTypecheckError("Type or constructor not found");
}
if (node->constructor_id_.has_value()) {
utils::IdType constructor_type_id = namespace_visitor_.GetGlobalInfo()->GetConstructorInfo(node->constructor_id_.value()).type_id;
if (node->type_id_.has_value() && node->type_id_.value() != constructor_type_id) {
error_handling::HandleTypecheckError("Contructor and type with same name have different types");
}
node->type_id_ = constructor_type_id;
}
if (node->type_id_.has_value()) {
node->type.type_id_ = node->type_id_.value();
}