From: Brendan Hansen Date: Fri, 8 Apr 2022 02:03:07 +0000 (-0500) Subject: bugfix with incorrect operator overload for struct literal X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=f242d3502c05eef3753b70ea9cc1addd54c401d4;p=onyx.git bugfix with incorrect operator overload for struct literal --- diff --git a/core/builtin.onyx b/core/builtin.onyx index aa889e9a..068f9803 100644 --- a/core/builtin.onyx +++ b/core/builtin.onyx @@ -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); } } diff --git a/core/container/map.onyx b/core/container/map.onyx index 25df3bd2..1ab17a08 100644 --- a/core/container/map.onyx +++ b/core/container/map.onyx @@ -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); diff --git a/core/container/set.onyx b/core/container/set.onyx index a565bacc..b99c4654 100644 --- a/core/container/set.onyx +++ b/core/container/set.onyx @@ -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); diff --git a/src/astnodes.c b/src/astnodes.c index cac8babd..5a33acc6 100644 --- a/src/astnodes.c +++ b/src/astnodes.c @@ -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;