bugfix with incorrect operator overload for struct literal
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Fri, 8 Apr 2022 02:03:07 +0000 (21:03 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Fri, 8 Apr 2022 02:03:07 +0000 (21:03 -0500)
core/builtin.onyx
core/container/map.onyx
core/container/set.onyx
src/astnodes.c

index aa889e9a530f9674a7d13d2d7fb247509a3d37bb..068f9803cc75cd8085ed50e3c2406abdc5474452 100644 (file)
@@ -194,7 +194,7 @@ __make_overload :: #match {
 }
 
 delete :: #match {
-    #precedence 1000 macro (x: ^$T, allocator := context.allocator) -> ^T {
+    #precedence 1000 macro (x: ^$T, allocator := context.allocator) {
         raw_free(allocator, x);
     }
 }
index 25df3bd2d24504a3be53b8902bfb1c895c43a373..1ab17a08661d326b5e0b8ff6ea0eb3fc6d4b1448 100644 (file)
@@ -60,13 +60,15 @@ make :: ($Key: type_expr, $Value: type_expr, default := __zero_value(Value)) ->
     return map;
 }
 
+#match (package builtin).__make_overload macro (x: ^Map($K, $V), allocator := context.allocator) => (package core.map).make(K, V);
+
 init :: (use map: ^Map($K, $V), default := __zero_value(V)) {
     __initialize(map);
 
     allocator = context.allocator;
     default_value = default;
 
-    memory.alloc_slice(^hashes, 8, allocator=allocator);
+    hashes = make([] u32, 8, allocator=allocator);
     array.fill(hashes, -1);
 
     array.init(^entries, allocator=allocator);
index a565baccbe5bd76f40b1a3f24c7b2f95cfd3d9c4..b99c4654a613fbd315b9c92b0609431ae0cbc939 100644 (file)
@@ -44,6 +44,8 @@ make :: ($T: type_expr, default := __zero_value(T), allocator := context.allocat
     return set;
 }
 
+#match (package builtin).__make_overload macro (x: ^Set, allocator: Allocator) => (package core.set).make(x.Elem_Type, allocator = allocator);
+
 init :: (set: ^Set($T), default := __zero_value(T), allocator := context.allocator) {
     set.allocator = allocator;
     set.default_value = default;
@@ -59,6 +61,8 @@ free :: (use set: ^Set) {
     array.free(^entries);
 }
 
+#match (package builtin).delete (package core.set).free
+
 insert :: (use set: ^Set, value: set.Elem_Type) {
     if hashes.data == null do init(set);
     lr := lookup(set, value);
index cac8babd1adfb17a1e28bc9e10411ddb04dd4282..5a33acc6cae814561c8f658d46a39ad62585eb7e 100644 (file)
@@ -534,7 +534,7 @@ TypeMatch unify_node_and_type_(AstTyped** pnode, Type* type, b32 permanent) {
     if (type == NULL) return TYPE_MATCH_FAILED;
     if (node == NULL) return TYPE_MATCH_FAILED;
 
-    if (node->kind == Ast_Kind_Struct_Literal && node->type_node == NULL) {
+    if (node->kind == Ast_Kind_Struct_Literal && (node->type_node == NULL && node->type == NULL)) {
         if (node->entity != NULL) return TYPE_MATCH_SUCCESS;
         if (type->kind == Type_Kind_VarArgs) type = type->VarArgs.elem;
         if (!type_is_sl_constructable(type)) return TYPE_MATCH_FAILED;