fixes, more information in errors

This commit is contained in:
ProgramSnail 2023-05-05 11:59:02 +03:00
parent a11ddbd25f
commit b686fe00fb
10 changed files with 356 additions and 65 deletions

View file

@ -18,8 +18,9 @@ void LinkSymbolsVisitor::Visit(Namespace* node) {
}
if (maybe_type.has_value() && maybe_typeclass.has_value()) {
error_handling::HandleTypecheckError("Ambigious namespace name (typeclass or type)");
error_handling::HandleTypecheckError("Ambigious namespace name (typeclass or type)", node->base);
}
if (maybe_type.has_value()) {
node->link_type_id_ = maybe_type.value();
}
@ -50,14 +51,14 @@ void LinkSymbolsVisitor::Visit(TypeExpression* node) { // TODO: check
node->constructor_id_ = namespace_visitor_.FindConstructor(path, node->type.type);
if (!node->type_id_.has_value() && !node->constructor_id_.has_value()) {
error_handling::HandleTypecheckError("Type or constructor not found");
error_handling::HandleTypecheckError("Type or constructor not found", node->base);
}
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");
error_handling::HandleTypecheckError("Contructor and type with same name have different types", node->base);
}
node->type_id_ = constructor_type_id;
@ -96,7 +97,7 @@ void LinkSymbolsVisitor::Visit(ParametrizedTypeclass* node) { // TODO: check
if (maybe_typeclass.has_value()) {
node->typeclass_id_ = maybe_typeclass.value();
} else {
error_handling::HandleTypecheckError("Type not found");
error_handling::HandleTypecheckError("Type not found", node->base);
}
}