aboutsummaryrefslogtreecommitdiff
path: root/src/compile/expressions.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-11-26 21:12:11 -0500
committerBruce Hill <bruce@bruce-hill.com>2025-11-26 21:12:11 -0500
commit3ad07260f369dc285e5ae856b78a58c3b13ee622 (patch)
tree7ba216c5482147ac53edaca62389029c34b4a66c /src/compile/expressions.c
parenta21f9ddfd05c643049c22bb52ab3a60f41933492 (diff)
Close loophole in `when` statements that allowed mutating inner field
members
Diffstat (limited to 'src/compile/expressions.c')
-rw-r--r--src/compile/expressions.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/compile/expressions.c b/src/compile/expressions.c
index a69a7d56..19e0672e 100644
--- a/src/compile/expressions.c
+++ b/src/compile/expressions.c
@@ -30,8 +30,7 @@ Text_t compile_maybe_incref(env_t *env, ast_t *ast, type_t *t) {
} else {
Text_t code = Texts("({ ", compile_declaration(t, Text("_tmp")), " = ", compile_to_type(env, ast, t), "; ",
"((", compile_type(t), "){");
- ast_t *tmp = WrapAST(ast, InlineCCode,
- .chunks = new (ast_list_t, .ast = WrapAST(ast, TextLiteral, Text("_tmp"))), .type = t);
+ ast_t *tmp = WrapLiteralCode(ast, Text("_tmp"), .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));