Commit 574c1a52

574c1a525953Merged

Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 1 file · ~1 modified

Description

codegen: coerce a poly key for an int-keyed hash masgn target under promote

A multiple-assignment hash-index target on an int-keyed hash (h[k] = ...) emits the key with emit_expr; route it through emit_int_expr so a poly key is unboxed. Safe no-op for non-poly keys.

Co-Authored-By: Claude Opus 4.8 [email protected]

Details

Commit
574c1a525953
Parent
ffba0284ac18

src/codegen_stmt.cmodifiedView file

@@ -3609,7 +3609,9 @@
36093609 if (!hn) { unsupported(c, id, "multiple assignment hash index target unknown kind"); continue; }
36103610 buf_printf(b, "sp_%sHash_set(", hn);
36113611 emit_expr(c, recv_id, b); buf_puts(b, ", ");
3612- emit_expr(c, idx_argv[0], b); buf_puts(b, ", ");
3612+ if (ty_hash_key(recv_t) == TY_INT) emit_int_expr(c, idx_argv[0], b);
3613+ else emit_expr(c, idx_argv[0], b);
3614+ buf_puts(b, ", ");
36133615 if (recv_t == TY_SYM_POLY_HASH || recv_t == TY_STR_POLY_HASH || recv_t == TY_POLY_POLY_HASH) {
36143616 TyKind valt = comp_ntype(c, els[i]);
36153617 char tmp_expr2[32]; snprintf(tmp_expr2, sizeof tmp_expr2, "_t%d", tmps[i]);