Fixing field access / Enum bugs

This commit is contained in:
Krzosa Karol
2022-06-10 19:44:52 +02:00
parent 70255c18cb
commit 862a820ec7
3 changed files with 10 additions and 6 deletions

View File

@@ -1,3 +1,4 @@
package Memory
Allocator_Kind :: enum Allocator_Kind :: enum
Null Null

View File

@@ -6,6 +6,8 @@ Test :: struct
test: Test test: Test
member := test.len member := test.len
thing: Memory.Allocator_Kind = Memory.Allocator_Kind.Heap
a_type :: S64 a_type :: S64
pointer_type :: *S64 pointer_type :: *S64
// null_pointer: pointer_type = null // null_pointer: pointer_type = null

View File

@@ -663,19 +663,20 @@ resolve_field_access(Ast_Expr *node, Ast_Scope *context){
field_access_scope = context; field_access_scope = context;
Operand op = resolve_expr(node, AST_CANT_BE_NULL); Operand op = resolve_expr(node, AST_CANT_BE_NULL);
if(op.type == type_type && is_enum(op.type_val)) op.type = op.type_val; Ast_Resolved_Type *type = op.type;
if(current) current->type = op.type; if(op.type == type_type && is_enum(op.type_val)) type = op.type_val;
if(is_pointer(op.type)) op.type = op.type->base; if(current) current->type = type;
type_complete(op.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"); compiler_error(node->pos, "Dot access");
} }
if(!next) if(!next)
return op; return op;
new_context = ((Ast_Decl *)op.type->ast)->scope; new_context = ((Ast_Decl *)type->ast)->scope;
} }
assert(next); assert(next);