aboutsummaryrefslogtreecommitdiff
path: root/src/check_expr.cpp
diff options
context:
space:
mode:
authorLaytan <laytanlaats@hotmail.com>2024-09-12 02:34:01 +0200
committerGitHub <noreply@github.com>2024-09-12 02:34:01 +0200
commit275f1cc0de4cd60799b7080a50d9a93e40f186cc (patch)
tree1f39402b16f74885ca1f02ff204db454cbc525ae /src/check_expr.cpp
parentc94829f4d38dc761bbdf1bc376aa3aa9235c54f2 (diff)
parent387f56634d337152d7aba07b740cf5821db9e67f (diff)
Merge pull request #4233 from laytan/fix-poly-variadic-reuse-slice
fix reuse of slice for varargs with poly types
Diffstat (limited to 'src/check_expr.cpp')
-rw-r--r--src/check_expr.cpp33
1 files changed, 17 insertions, 16 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp
index 760551a72..f1bf86992 100644
--- a/src/check_expr.cpp
+++ b/src/check_expr.cpp
@@ -6204,22 +6204,6 @@ gb_internal CallArgumentError check_call_arguments_internal(CheckerContext *c, A
Entity *vt = pt->params->Tuple.variables[pt->variadic_index];
o.type = vt->type;
-
- // NOTE(bill, 2024-07-14): minimize the stack usage for variadic parameters with the backing array
- if (c->decl) {
- bool found = false;
- for (auto &vr : c->decl->variadic_reuses) {
- if (are_types_identical(vt->type, vr.slice_type)) {
- vr.max_count = gb_max(vr.max_count, variadic_operands.count);
- found = true;
- break;
- }
- }
- if (!found) {
- array_add(&c->decl->variadic_reuses, VariadicReuseData{vt->type, variadic_operands.count});
- }
- }
-
} else {
dummy_argument_count += 1;
o.type = t_untyped_nil;
@@ -6413,6 +6397,23 @@ gb_internal CallArgumentError check_call_arguments_internal(CheckerContext *c, A
}
score += eval_param_and_score(c, o, t, err, true, var_entity, show_error);
}
+
+ if (!vari_expand && variadic_operands.count != 0) {
+ // NOTE(bill, 2024-07-14): minimize the stack usage for variadic parameters with the backing array
+ if (c->decl) {
+ bool found = false;
+ for (auto &vr : c->decl->variadic_reuses) {
+ if (are_types_identical(slice, vr.slice_type)) {
+ vr.max_count = gb_max(vr.max_count, variadic_operands.count);
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ array_add(&c->decl->variadic_reuses, VariadicReuseData{slice, variadic_operands.count});
+ }
+ }
+ }
}
if (data) {