fixed bug with partial constructed polymorphic structs for #match
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Sat, 23 Apr 2022 04:21:13 +0000 (23:21 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Sat, 23 Apr 2022 04:21:13 +0000 (23:21 -0500)
core/container/set.onyx
src/checker.c
src/types.c

index b99c4654a613fbd315b9c92b0609431ae0cbc939..b181a887bb1c50377a2e86ffb15c4472f1cf2990 100644 (file)
@@ -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) {
index 6e6cdc9c7db8eff057e36c8ca15096e7f0fc95ab..b48439a7833578a5dcdb07eb2d8303b053cc96b1 100644 (file)
@@ -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;
index e408b6927aef8f73f4bb9cc0647a36a59a415148..9665af33472d0f5e317421834368e43532a738b4 100644 (file)
@@ -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);