From: Brendan Hansen Date: Wed, 30 Dec 2020 15:33:23 +0000 (-0600) Subject: small bugfix with enum values being of the wrong type X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=a38e6c5aae3cf1e6ddce9d0d785d655fa42ae98e;p=onyx.git small bugfix with enum values being of the wrong type --- diff --git a/onyx b/onyx index 08c9d5ca..4d1f1a5c 100755 Binary files a/onyx and b/onyx differ diff --git a/progs/odin_example.onyx b/progs/odin_example.onyx index 090eadd6..2642bbc2 100644 --- a/progs/odin_example.onyx +++ b/progs/odin_example.onyx @@ -94,6 +94,7 @@ main :: proc (args: [] cstr) { printf("%f\n", a.float); e := Entity.{ Vec2.{ 1, 2 } }; + printf("Entity(%i, %i)\n", e.x, e.y); { foo : [5] [2] u32; diff --git a/src/onyxsymres.c b/src/onyxsymres.c index fef857b5..6718dfb6 100644 --- a/src/onyxsymres.c +++ b/src/onyxsymres.c @@ -851,6 +851,8 @@ static void symres_enum(AstEnumType* enum_node) { enum_node->backing_type = type_build_from_ast(semstate.allocator, enum_node->backing); enum_node->scope = scope_create(semstate.node_allocator, NULL, enum_node->token->pos); + type_build_from_ast(semstate.node_allocator, (AstType *) enum_node); + u64 next_assign_value = (enum_node->flags & Ast_Flag_Enum_Is_Flags) ? 1 : 0; bh_arr_each(AstEnumValue *, value, enum_node->values) { symbol_introduce(enum_node->scope, (*value)->token, (AstNode *) *value); @@ -872,9 +874,9 @@ static void symres_enum(AstEnumType* enum_node) { } else { AstNumLit* num = onyx_ast_node_new(semstate.node_allocator, sizeof(AstNumLit), Ast_Kind_NumLit); num->value.l = next_assign_value; - num->type_node = enum_node->backing; - num->type = enum_node->backing_type; num->flags |= Ast_Flag_Comptime; + num->type = enum_node->etcache; + (*value)->value = num; }