aboutsummaryrefslogtreecommitdiff
path: root/src/check_builtin.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/check_builtin.cpp')
-rw-r--r--src/check_builtin.cpp24
1 files changed, 18 insertions, 6 deletions
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<Ast *> 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<Ast *> 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]));