aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-11-29 11:14:14 -0500
committerBruce Hill <bruce@bruce-hill.com>2025-11-29 11:14:14 -0500
commit06f5270edfa8231025125909880af27d42e2e52b (patch)
tree91958db17b75e1db7274c33ab93968fa6725b515 /src
parent3867fa93d39d92fc049dcde08cb322d9a78e3744 (diff)
Fix accidental naming collision with _tmp var
Diffstat (limited to 'src')
-rw-r--r--src/compile/expressions.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/compile/expressions.c b/src/compile/expressions.c
index 19e0672e..8b339352 100644
--- a/src/compile/expressions.c
+++ b/src/compile/expressions.c
@@ -28,9 +28,12 @@ Text_t compile_maybe_incref(env_t *env, ast_t *ast, type_t *t) {
}
return Texts(code, "})");
} else {
- Text_t code = Texts("({ ", compile_declaration(t, Text("_tmp")), " = ", compile_to_type(env, ast, t), "; ",
+ static int64_t tmp_index = 1;
+ Text_t tmp_name = Texts("_tmp", tmp_index);
+ tmp_index += 1;
+ Text_t code = Texts("({ ", compile_declaration(t, tmp_name), " = ", compile_to_type(env, ast, t), "; ",
"((", compile_type(t), "){");
- ast_t *tmp = WrapLiteralCode(ast, Text("_tmp"), .type = t);
+ ast_t *tmp = WrapLiteralCode(ast, tmp_name, .type = t);
for (arg_t *field = Match(t, StructType)->fields; field; field = field->next) {
Text_t val = compile_maybe_incref(env, WrapAST(ast, FieldAccess, .fielded = tmp, .field = field->name),
get_arg_type(env, field));