aboutsummaryrefslogtreecommitdiff
path: root/src/check_decl.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2021-05-12 23:02:57 +0100
committergingerBill <bill@gingerbill.org>2021-05-12 23:02:57 +0100
commitda9cabc3344900059d0837729e54e09e58089ae9 (patch)
treeb10815b8d9a0ddde4b17b815c6be7676c0aea472 /src/check_decl.cpp
parentd962cfdc6bd1865c7df302d08af237027533437f (diff)
Fix #682
Diffstat (limited to 'src/check_decl.cpp')
-rw-r--r--src/check_decl.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/check_decl.cpp b/src/check_decl.cpp
index f43248593..baabe4184 100644
--- a/src/check_decl.cpp
+++ b/src/check_decl.cpp
@@ -376,6 +376,7 @@ void override_entity_in_scope(Entity *original_entity, Entity *new_entity) {
void check_const_decl(CheckerContext *ctx, Entity *e, Ast *type_expr, Ast *init, Type *named_type) {
GB_ASSERT(e->type == nullptr);
GB_ASSERT(e->kind == Entity_Constant);
+ init = unparen_expr(init);
if (e->flags & EntityFlag_Visited) {
e->type = t_invalid;
@@ -409,6 +410,18 @@ void check_const_decl(CheckerContext *ctx, Entity *e, Ast *type_expr, Ast *init,
e->kind = Entity_TypeName;
e->type = nullptr;
+ if (entity != nullptr && entity->type != nullptr &&
+ is_type_polymorphic_record_unspecialized(entity->type)) {
+ DeclInfo *decl = decl_info_of_entity(e);
+ if (decl != nullptr) {
+ if (decl->attributes.count > 0) {
+ error(decl->attributes[0], "Constant alias declarations cannot have attributes");
+ }
+ }
+
+ override_entity_in_scope(e, entity);
+ return;
+ }
check_type_decl(ctx, e, ctx->decl->init_expr, named_type);
return;
}