Commit 1cfd2821

1cfd2821dd3eMerged

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

Description

codegen: unbox a poly key in a value-form hash []= to the hash key type

h[k] = v in expression position emitted the key via emit_expr, so a key widened to poly (promote mode) was passed raw into a typed-key hash setter (sp_IntStrHash_set(h, <sp_RbVal>, ...)). Route it through emit_hash_key, which unboxes a poly key to the hash's key type. Fixes bundle_class_06.

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

Details

Commit
1cfd2821dd3e
Parent
b7fb0698b8a3

src/codegen_call.cmodifiedView file

@@ -8893,7 +8893,8 @@
88938893 else emit_expr(c, argv[1], b);
88948894 buf_printf(b, "; if (sp_gc_is_frozen("); emit_expr(c, recv, b); buf_puts(b, ")) sp_raise_frozen_hash(); ");
88958895 buf_printf(b, "sp_%sHash_set(", hn); emit_expr(c, recv, b); buf_puts(b, ", ");
8896- if (rt == TY_POLY_POLY_HASH) emit_boxed(c, argv[0], b); else emit_expr(c, argv[0], b);
8896+ if (rt == TY_POLY_POLY_HASH) emit_boxed(c, argv[0], b);
8897+ else emit_hash_key(c, argv[0], ty_hash_key(rt), b); /* unbox a poly key to the hash's key type */
88978898 buf_puts(b, ", ");
88988899 char tvn[32]; snprintf(tvn, sizeof tvn, "_t%d", tv);
88998900 if (is_poly_hash && vt != TY_POLY) {