From 5a9ac7d9067e5ffeb1e67d55fd54b59c888d4e34 Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Fri, 22 Apr 2022 23:21:13 -0500 Subject: [PATCH] fixed bug with partial constructed polymorphic structs for #match --- core/container/set.onyx | 4 ++-- src/checker.c | 8 ++++---- src/types.c | 6 ++++++ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/core/container/set.onyx b/core/container/set.onyx index b99c4654..b181a887 100644 --- a/core/container/set.onyx +++ b/core/container/set.onyx @@ -9,8 +9,8 @@ package core.set use package core.intrinsics.onyx { __zero_value } #local SetValue :: interface (t: $T) { - { hash.to_u32(T) } -> u32; - { T == T } -> bool; + { hash.to_u32(t) } -> u32; + { t == t } -> bool; } Set :: struct (Elem_Type: type_expr) where SetValue(Elem_Type) { diff --git a/src/checker.c b/src/checker.c index 6e6cdc9c..b48439a7 100644 --- a/src/checker.c +++ b/src/checker.c @@ -2473,10 +2473,10 @@ CheckStatus check_type(AstType** ptype) { break; } - case Ast_Kind_Pointer_Type: CHECK(type, &((AstPointerType *) type)->elem); break; - case Ast_Kind_Slice_Type: CHECK(type, &((AstSliceType *) type)->elem); break; - case Ast_Kind_DynArr_Type: CHECK(type, &((AstDynArrType *) type)->elem); break; - case Ast_Kind_VarArg_Type: CHECK(type, &((AstVarArgType *) type)->elem); break; + case Ast_Kind_Pointer_Type: ((AstPointerType *) type)->elem->flags |= type->flags & Ast_Flag_Header_Check_No_Error; CHECK(type, &((AstPointerType *) type)->elem); break; + case Ast_Kind_Slice_Type: ((AstSliceType *) type)->elem->flags |= type->flags & Ast_Flag_Header_Check_No_Error; CHECK(type, &((AstSliceType *) type)->elem); break; + case Ast_Kind_DynArr_Type: ((AstDynArrType *) type)->elem->flags |= type->flags & Ast_Flag_Header_Check_No_Error; CHECK(type, &((AstDynArrType *) type)->elem); break; + case Ast_Kind_VarArg_Type: ((AstVarArgType *) type)->elem->flags |= type->flags & Ast_Flag_Header_Check_No_Error; CHECK(type, &((AstVarArgType *) type)->elem); break; case Ast_Kind_Function_Type: { AstFunctionType* ftype = (AstFunctionType *) type; diff --git a/src/types.c b/src/types.c index e408b692..9665af33 100644 --- a/src/types.c +++ b/src/types.c @@ -253,6 +253,7 @@ Type* type_build_from_ast(bh_allocator alloc, AstType* type_node) { switch (type_node->kind) { case Ast_Kind_Pointer_Type: { + // ((AstPointerType *) type_node)->elem->flags |= type_node->flags & Ast_Flag_Header_Check_No_Error; Type* ptr_type = type_make_pointer(alloc, type_build_from_ast(alloc, ((AstPointerType *) type_node)->elem)); if (ptr_type) ptr_type->ast_type = type_node; return ptr_type; @@ -697,6 +698,7 @@ Type* type_build_compound_type(bh_allocator alloc, AstCompound* compound) { Type* type_make_pointer(bh_allocator alloc, Type* to) { if (to == NULL) return NULL; + if (to == (Type *) &node_that_signals_failure) return to; assert(to->id > 0); u64 ptr_id = bh_imap_get(&type_pointer_map, to->id); @@ -719,6 +721,7 @@ Type* type_make_pointer(bh_allocator alloc, Type* to) { Type* type_make_array(bh_allocator alloc, Type* to, u32 count) { if (to == NULL) return NULL; + if (to == (Type *) &node_that_signals_failure) return to; assert(to->id > 0); u64 key = ((((u64) to->id) << 32) | (u64) count); @@ -742,6 +745,7 @@ Type* type_make_array(bh_allocator alloc, Type* to, u32 count) { Type* type_make_slice(bh_allocator alloc, Type* of) { if (of == NULL) return NULL; + if (of == (Type *) &node_that_signals_failure) return of; assert(of->id > 0); u64 slice_id = bh_imap_get(&type_slice_map, of->id); @@ -763,6 +767,7 @@ Type* type_make_slice(bh_allocator alloc, Type* of) { Type* type_make_dynarray(bh_allocator alloc, Type* of) { if (of == NULL) return NULL; + if (of == (Type *) &node_that_signals_failure) return of; assert(of->id > 0); u64 dynarr_id = bh_imap_get(&type_dynarr_map, of->id); @@ -784,6 +789,7 @@ Type* type_make_dynarray(bh_allocator alloc, Type* of) { Type* type_make_varargs(bh_allocator alloc, Type* of) { if (of == NULL) return NULL; + if (of == (Type *) &node_that_signals_failure) return of; assert(of->id > 0); u64 vararg_id = bh_imap_get(&type_vararg_map, of->id); -- 2.25.1