aboutsummaryrefslogtreecommitdiff
path: root/src/check_decl.cpp
diff options
context:
space:
mode:
authorColin Davidson <colrdavidson@gmail.com>2024-11-20 15:51:08 -0800
committerColin Davidson <colrdavidson@gmail.com>2024-11-20 15:51:08 -0800
commitd60fb5a44e4d2e371562fd38947f8125b06bceb9 (patch)
tree4e924ee102c2af7b30d29017ab716ed00c51ab26 /src/check_decl.cpp
parentf3ab14b8ccb45d0fef8a96937635bdf0943ce7d6 (diff)
parent3229f4668dfaa5f43a374bc549f42661b002699d (diff)
update to master
Diffstat (limited to 'src/check_decl.cpp')
-rw-r--r--src/check_decl.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/check_decl.cpp b/src/check_decl.cpp
index 3b532a727..60eb030ff 100644
--- a/src/check_decl.cpp
+++ b/src/check_decl.cpp
@@ -88,11 +88,12 @@ gb_internal Type *check_init_variable(CheckerContext *ctx, Entity *e, Operand *o
e->type = t_invalid;
return nullptr;
} else if (is_type_polymorphic(t)) {
- Entity *e = entity_of_node(operand->expr);
- if (e == nullptr) {
+ Entity *e2 = entity_of_node(operand->expr);
+ if (e2 == nullptr) {
+ e->type = t_invalid;
return nullptr;
}
- if (e->state.load() != EntityState_Resolved) {
+ if (e2->state.load() != EntityState_Resolved) {
gbString str = type_to_string(t);
defer (gb_string_free(str));
error(e->token, "Invalid use of a polymorphic type '%s' in %.*s", str, LIT(context_name));
@@ -232,6 +233,10 @@ gb_internal bool check_override_as_type_due_to_aliasing(CheckerContext *ctx, Ent
// until there is a proper delaying system to try declaration again if they
// have failed.
+ if (e->type != nullptr && is_type_typed(e->type)) {
+ return false;
+ }
+
e->kind = Entity_TypeName;
check_type_decl(ctx, e, init, named_type);
return true;