From e80d659072d3fa0349525395b9f7032a3bc3c720 Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Sat, 25 Feb 2023 22:50:29 -0600 Subject: [PATCH] bugfix with matching function using array literals --- compiler/src/astnodes.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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) { -- 2.25.1