aboutsummaryrefslogtreecommitdiff
path: root/src/check_decl.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2023-05-18 11:52:16 +0100
committergingerBill <bill@gingerbill.org>2023-05-18 11:52:16 +0100
commit56c0d32ea0c81ad9913e4e512952b3be25688504 (patch)
treefee942c4699ad9da4cc96bbc5d0a27c46e5f710f /src/check_decl.cpp
parentc0e84b05923cef2d3fb1d6c0ef5b9e9a119363fe (diff)
Fix #2526
Diffstat (limited to 'src/check_decl.cpp')
-rw-r--r--src/check_decl.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/check_decl.cpp b/src/check_decl.cpp
index a984f87a3..e97e86e8b 100644
--- a/src/check_decl.cpp
+++ b/src/check_decl.cpp
@@ -43,14 +43,20 @@ gb_internal Type *check_init_variable(CheckerContext *ctx, Entity *e, Operand *o
}
if (operand->mode == Addressing_Type) {
- if (e->type != nullptr && is_type_typeid(e->type)) {
+ if (e->type != nullptr && is_type_typeid(e->type) && !is_type_polymorphic(operand->type)) {
add_type_info_type(ctx, operand->type);
add_type_and_value(ctx, operand->expr, Addressing_Value, e->type, exact_value_typeid(operand->type));
return e->type;
} else {
+ ERROR_BLOCK();
+
gbString t = type_to_string(operand->type);
defer (gb_string_free(t));
- error(operand->expr, "Cannot assign a type '%s' to variable '%.*s'", t, LIT(e->token.string));
+ if (is_type_polymorphic(operand->type)) {
+ error(operand->expr, "Cannot assign a non-specialized polymorphic type '%s' to variable '%.*s'", t, LIT(e->token.string));
+ } else {
+ error(operand->expr, "Cannot assign a type '%s' to variable '%.*s'", t, LIT(e->token.string));
+ }
if (e->type == nullptr) {
error_line("\tThe type of the variable '%.*s' cannot be inferred as a type does not have a default type\n", LIT(e->token.string));
}
@@ -59,8 +65,6 @@ gb_internal Type *check_init_variable(CheckerContext *ctx, Entity *e, Operand *o
}
}
-
-
if (e->type == nullptr) {
// NOTE(bill): Use the type of the operand