diff --git a/enums.kl b/enums.kl index 6c2da0f..4ad9bd4 100644 --- a/enums.kl +++ b/enums.kl @@ -1,3 +1,4 @@ +package Memory Allocator_Kind :: enum Null diff --git a/lambdas.kl b/lambdas.kl index aa3e125..cf43486 100644 --- a/lambdas.kl +++ b/lambdas.kl @@ -6,6 +6,8 @@ Test :: struct test: Test member := test.len +thing: Memory.Allocator_Kind = Memory.Allocator_Kind.Heap + a_type :: S64 pointer_type :: *S64 // null_pointer: pointer_type = null diff --git a/typechecking.cpp b/typechecking.cpp index 6cecacf..c77f93b 100644 --- a/typechecking.cpp +++ b/typechecking.cpp @@ -663,19 +663,20 @@ resolve_field_access(Ast_Expr *node, Ast_Scope *context){ field_access_scope = context; Operand op = resolve_expr(node, AST_CANT_BE_NULL); - if(op.type == type_type && is_enum(op.type_val)) op.type = op.type_val; - if(current) current->type = op.type; - if(is_pointer(op.type)) op.type = op.type->base; - type_complete(op.type); + Ast_Resolved_Type *type = op.type; + if(op.type == type_type && is_enum(op.type_val)) type = op.type_val; + if(current) current->type = type; + if(is_pointer(type)) type = type->base; + type_complete(type); - if(next && !is_struct(op.type) && !is_enum(op.type)){ + if(next && !is_struct(type) && !is_enum(type)){ compiler_error(node->pos, "Dot access"); } if(!next) return op; - new_context = ((Ast_Decl *)op.type->ast)->scope; + new_context = ((Ast_Decl *)type->ast)->scope; } assert(next);