mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-08 16:48:18 +00:00
Allow for base enum type with an enum declaration
This commit is contained in:
@@ -486,6 +486,12 @@ i64 check_distance_between_types(CheckerContext *c, Operand *operand, Type *type
|
||||
}
|
||||
}
|
||||
|
||||
if (is_type_enum(dst) && are_types_identical(dst->Enum.base_type, operand->type)) {
|
||||
if (c->in_enum_type) {
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (are_types_identical(dst, src) && (!is_type_named(dst) || !is_type_named(src))) {
|
||||
return 1;
|
||||
|
||||
@@ -1931,6 +1931,7 @@ bool check_type_internal(CheckerContext *ctx, AstNode *e, Type **type, Type *nam
|
||||
bool ips = ctx->in_polymorphic_specialization;
|
||||
defer (ctx->in_polymorphic_specialization = ips);
|
||||
ctx->in_polymorphic_specialization = false;
|
||||
ctx->in_enum_type = true;
|
||||
|
||||
*type = alloc_type_enum();
|
||||
set_base_type(named_type, *type);
|
||||
|
||||
@@ -549,9 +549,6 @@ void init_universal_scope(void) {
|
||||
add_global_constant(str_lit("false"), t_untyped_bool, exact_value_bool(false));
|
||||
|
||||
add_global_entity(alloc_entity_nil(str_lit("nil"), t_untyped_nil));
|
||||
// add_global_entity(alloc_entity_library_name(universal_scope,
|
||||
// make_token_ident(str_lit("__llvm_core")), t_invalid,
|
||||
// str_lit(""), str_lit("__llvm_core")));
|
||||
|
||||
// TODO(bill): Set through flags in the compiler
|
||||
add_global_string_constant(str_lit("ODIN_VENDOR"), bc->ODIN_VENDOR);
|
||||
|
||||
@@ -343,6 +343,7 @@ struct CheckerContext {
|
||||
CheckerTypePath *type_path;
|
||||
isize type_level; // TODO(bill): Actually handle correctly
|
||||
|
||||
bool in_enum_type;
|
||||
bool collect_delayed_decls;
|
||||
bool allow_polymorphic_types;
|
||||
bool no_polymorphic_errors;
|
||||
|
||||
@@ -1030,7 +1030,6 @@ AstNode *ast_attribute(AstFile *f, Token token, Token open, Token close, Array<A
|
||||
|
||||
|
||||
bool next_token0(AstFile *f) {
|
||||
// Token prev = f->curr_token;
|
||||
if (f->curr_token_index+1 < f->tokens.count) {
|
||||
f->curr_token = f->tokens[++f->curr_token_index];
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user