aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2023-08-08 15:10:57 +0100
committergingerBill <bill@gingerbill.org>2023-08-08 15:10:57 +0100
commitb72f009d87e010a022231a7222f2232c852aefdb (patch)
tree994c9743601c121533aa9d8bd03cdae9796547c8 /src
parent2181e0fc279b396710ac9b864e566243d15eaf86 (diff)
Disallow aliasing of `any` and `typeid`
Diffstat (limited to 'src')
-rw-r--r--src/check_decl.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/check_decl.cpp b/src/check_decl.cpp
index 587d749b4..86a887157 100644
--- a/src/check_decl.cpp
+++ b/src/check_decl.cpp
@@ -321,7 +321,14 @@ gb_internal void check_type_decl(CheckerContext *ctx, Entity *e, Ast *init_expr,
gb_string_free(str);
is_distinct = false;
}
+ } else {
+ if (is_type_typeid(e->type)) {
+ error(init_expr, "'typeid' cannot be aliased");
+ } else if (is_type_any(e->type)) {
+ error(init_expr, "'any' cannot be aliased");
+ }
}
+
if (!is_distinct) {
e->type = bt;
named->Named.base = bt;