Переглянути джерело

Disallow aliasing of `any` and `typeid`

gingerBill 2 роки тому
батько
коміт
b72f009d87
1 змінених файлів з 7 додано та 0 видалено
  1. 7 0
      src/check_decl.cpp

+ 7 - 0
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;