aboutsummaryrefslogtreecommitdiff
path: root/src/check_decl.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2019-03-22 13:55:29 +0000
committergingerBill <bill@gingerbill.org>2019-03-22 13:55:29 +0000
commit886054f0f87217a47c7a18098bc708eaf0179447 (patch)
tree7d6fd35e3253d7bf46464a8a33b3e5b84d2b217c /src/check_decl.cpp
parent0e1cfa5a0aa9b68a34a15a6f293f729d66e0ade4 (diff)
Add error message for when trying to assign a type to a variable.
Diffstat (limited to 'src/check_decl.cpp')
-rw-r--r--src/check_decl.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/check_decl.cpp b/src/check_decl.cpp
index 3f5ef042f..5ede584aa 100644
--- a/src/check_decl.cpp
+++ b/src/check_decl.cpp
@@ -40,6 +40,14 @@ Type *check_init_variable(CheckerContext *ctx, Entity *e, Operand *operand, Stri
return nullptr;
}
+ if (operand->mode == Addressing_Type) {
+ gbString t = type_to_string(operand->type);
+ error(operand->expr, "Cannot assign a type '%s' to variable '%.*s'", t, LIT(e->token.string));
+ gb_string_free(t);
+ e->type = operand->type;
+ return nullptr;
+ }
+
if (e->type == nullptr) {