From: Brendan Hansen Date: Sun, 26 Feb 2023 04:50:29 +0000 (-0600) Subject: bugfix with matching function using array literals X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=e80d659072d3fa0349525395b9f7032a3bc3c720;p=onyx.git bugfix with matching function using array literals --- diff --git a/compiler/src/astnodes.c b/compiler/src/astnodes.c index 1dcfb843..b1a5f984 100644 --- a/compiler/src/astnodes.c +++ b/compiler/src/astnodes.c @@ -595,7 +595,16 @@ TypeMatch unify_node_and_type_(AstTyped** pnode, Type* type, b32 permanent) { // If this shouldn't make permanent changes and submit entities, // just assume that it works and don't submit the entities. - if (!permanent) return TYPE_MATCH_SUCCESS; + if (!permanent) { + // + // This only works if the destination type is an array or slice, + // otherwise there is no way the array literal would match. + if (type->kind != Type_Kind_Array && type->kind != Type_Kind_Slice) { + return TYPE_MATCH_FAILED; + } + + return TYPE_MATCH_SUCCESS; + } Type* array_type=NULL; switch (type->kind) {