mirror of
https://github.com/odin-lang/Odin.git
synced 2026-01-04 20:17:48 +00:00
typeid as keyword (ready to implement polymorphic name parameters)
This commit is contained in:
@@ -232,12 +232,11 @@ void check_type_decl(CheckerContext *ctx, Entity *e, Ast *type_expr, Type *def)
|
||||
GB_ASSERT(e->type == nullptr);
|
||||
|
||||
DeclInfo *decl = decl_info_of_entity(e);
|
||||
if (decl != nullptr && total_attribute_count(decl) > 0) {
|
||||
error(decl->attributes[0], "Attributes are not allowed on type declarations");
|
||||
if (decl != nullptr) {
|
||||
check_decl_attributes(ctx, decl->attributes, const_decl_attribute, nullptr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool is_distinct = is_type_distinct(type_expr);
|
||||
Ast *te = remove_type_alias_clutter(type_expr);
|
||||
e->type = t_invalid;
|
||||
@@ -254,6 +253,11 @@ void check_type_decl(CheckerContext *ctx, Entity *e, Ast *type_expr, Type *def)
|
||||
check_type_path_pop(ctx);
|
||||
|
||||
named->Named.base = base_type(bt);
|
||||
|
||||
if (is_distinct && is_type_typeid(e->type)) {
|
||||
error(type_expr, "'distinct' cannot be applied to 'typeid'");
|
||||
is_distinct = false;
|
||||
}
|
||||
if (!is_distinct) {
|
||||
e->type = bt;
|
||||
named->Named.base = bt;
|
||||
@@ -393,8 +397,8 @@ void check_const_decl(CheckerContext *ctx, Entity *e, Ast *type_expr, Ast *init,
|
||||
|
||||
|
||||
DeclInfo *decl = decl_info_of_entity(e);
|
||||
if (decl != nullptr && total_attribute_count(decl) > 0) {
|
||||
error(decl->attributes[0], "Attributes are not allowed on constant value declarations");
|
||||
if (decl != nullptr) {
|
||||
check_decl_attributes(ctx, decl->attributes, const_decl_attribute, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user