mirror of
https://codeberg.org/ProgramSnail/lang_2023.git
synced 2025-12-28 17:58:44 +00:00
part of type_check_visitor
This commit is contained in:
parent
94ef8702fb
commit
f7e985a448
10 changed files with 377 additions and 88 deletions
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue