diff --git a/ccodegen.cpp b/ccodegen.cpp index ee73e80..7ec6e00 100644 --- a/ccodegen.cpp +++ b/ccodegen.cpp @@ -26,7 +26,9 @@ gen_simple_decl_prefix(Ast_Resolved_Type *ast){ case TYPE_POINTER: gen_simple_decl_prefix(ast->base); gen("*"); break; case TYPE_ARRAY: gen_simple_decl_prefix(ast->base); break; case TYPE_LAMBDA:break; - case TYPE_ENUM: + case TYPE_ENUM:{ + gen_simple_decl_prefix(ast->base); break; + }break; case TYPE_STRUCT: { auto constant = (Ast_Decl *)ast->ast; auto name = constant->name; diff --git a/enums.kl b/enums.kl index 4ad9bd4..dde79a0 100644 --- a/enums.kl +++ b/enums.kl @@ -3,7 +3,7 @@ package Memory Allocator_Kind :: enum Null Arena - Heap + Heap :: 4 kind := Allocator_Kind.Heap diff --git a/lambdas.kl b/lambdas.kl index cf43486..f6f2724 100644 --- a/lambdas.kl +++ b/lambdas.kl @@ -6,7 +6,7 @@ Test :: struct test: Test member := test.len -thing: Memory.Allocator_Kind = Memory.Allocator_Kind.Heap +enum_val: Memory.Allocator_Kind = Memory.Allocator_Kind.Heap a_type :: S64 pointer_type :: *S64 diff --git a/parsing.cpp b/parsing.cpp index 943302e..3653292 100644 --- a/parsing.cpp +++ b/parsing.cpp @@ -537,7 +537,8 @@ parse_enum(Token *pos){ Ast_Scope *scope = begin_decl_scope(scratch, token_get()); do{ Token *name = token_expect(TK_Identifier); - Ast_Expr *value = parse_assign_expr(); + Ast_Expr *value = 0; + if(token_match(TK_DoubleColon)) value = parse_expr(); Ast_Decl *member = ast_const(name, name->intern_val, value); member->flags = set_flag(member->flags, AST_AGGREGATE_CHILD); scope->decls.add(member); diff --git a/typechecking.cpp b/typechecking.cpp index c77f93b..66ff1a8 100644 --- a/typechecking.cpp +++ b/typechecking.cpp @@ -23,6 +23,8 @@ convert_untyped_to_typed(Token *pos, Value a, Ast_Resolved_Type *new_type){ if(is_int(a.type) && is_int(new_type)) assert(a.type == untyped_int); + else if(is_int(a.type) && is_enum(new_type)) + ; else if(is_int(a.type) && is_float(new_type)) a.f64_val = bigint_as_float(&a.big_int_val); // @leak bigint else if(is_int(a.type) && is_pointer(new_type)) diff --git a/typechecking.h b/typechecking.h index d1b6e9f..7f79ac2 100644 --- a/typechecking.h +++ b/typechecking.h @@ -181,7 +181,7 @@ function Ast_Resolved_Type * type_enum(Ast_Decl *ast){ Ast_Resolved_Type *type = resolve_typespec(ast->typespec, AST_CAN_BE_NULL); if(!type){ - type = untyped_int; + type = type_s64; } Ast_Resolved_Type *result = type_new(pctx->perm, TYPE_ENUM, type->size, type->align);