Forbid redefenition of builtin types
This commit is contained in:
@ -52,7 +52,8 @@ namespace boot
|
||||
{
|
||||
for (type_definition *const type : program->types)
|
||||
{
|
||||
if (!this->unresolved.insert({ type->identifier, std::make_shared<alias_type>() }).second)
|
||||
if (!this->unresolved.insert({ type->identifier, std::make_shared<alias_type>(type->identifier) }).second
|
||||
|| this->symbols->contains(type->identifier))
|
||||
{
|
||||
add_error<already_declared_error>(type->identifier, this->input_file, type->position());
|
||||
}
|
||||
@ -61,6 +62,11 @@ namespace boot
|
||||
{
|
||||
type->accept(this);
|
||||
}
|
||||
for (auto& unresolved : this->unresolved)
|
||||
{
|
||||
auto info = std::make_shared<type_info>(type_info(type(unresolved.second)));
|
||||
this->symbols->enter(std::move(unresolved.first), info);
|
||||
}
|
||||
}
|
||||
|
||||
void declaration_visitor::visit(type_definition *definition)
|
||||
@ -79,7 +85,7 @@ namespace boot
|
||||
{
|
||||
this->current_type = type(unresolved_alias->second);
|
||||
}
|
||||
else if (auto from_symbol_table = this->symbols.lookup(type_expression->name))
|
||||
else if (auto from_symbol_table = this->symbols->lookup(type_expression->name))
|
||||
{
|
||||
this->current_type = from_symbol_table->is_type()->symbol;
|
||||
}
|
||||
|
@ -247,6 +247,11 @@ namespace boot
|
||||
return tag == type_tag::empty;
|
||||
}
|
||||
|
||||
alias_type::alias_type(const std::string& name)
|
||||
: name(name), reference()
|
||||
{
|
||||
}
|
||||
|
||||
pointer_type::pointer_type(type base)
|
||||
: base(base)
|
||||
{
|
||||
|
Reference in New Issue
Block a user