From 26b3a4d182788a08ea1d9eb8d7c3b49235065cb6 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Fri, 10 Oct 2025 12:09:41 +0100 Subject: Handle concatenation at the end --- src/check_builtin.cpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'src/check_builtin.cpp') diff --git a/src/check_builtin.cpp b/src/check_builtin.cpp index fcd2200dc..530efb3c8 100644 --- a/src/check_builtin.cpp +++ b/src/check_builtin.cpp @@ -4923,11 +4923,6 @@ gb_internal bool check_builtin_procedure(CheckerContext *c, Operand *operand, As Type *elem_type = base_any_array_type(lhs.type); - Array new_elems = {}; - array_init(&new_elems, heap_allocator()); - - array_add_elems(&new_elems, lhs_cl->elems.data, lhs_cl->elems.count); - for (isize i = 1; i < ce->args.count; i++) { Operand extra = {}; if (is_type_slice(lhs.type)) { @@ -4988,8 +4983,25 @@ gb_internal bool check_builtin_procedure(CheckerContext *c, Operand *operand, As return false; } } + } + + isize count_needed = 0; - array_add_elems(&new_elems, extra_cl->elems.data, extra_cl->elems.count); + for (Ast *arg : ce->args) { + ExactValue value = arg->tav.value; + GB_ASSERT(value.kind == ExactValue_Compound); + ast_node(cl, CompoundLit, value.value_compound); + count_needed += cl->elems.count; + } + + Array new_elems = {}; + array_init(&new_elems, permanent_allocator(), 0, count_needed); + + for (Ast *arg : ce->args) { + ExactValue value = arg->tav.value; + GB_ASSERT(value.kind == ExactValue_Compound); + ast_node(cl, CompoundLit, value.value_compound); + array_add_elems(&new_elems, cl->elems.data, cl->elems.count); } Ast *new_compound_lit = ast_compound_lit(lhs.expr->file(), nullptr, new_elems, ast_token(lhs.expr), ast_end_token(ce->args[ce->args.count-1])); -- cgit v1.2.3