Commit 5076281b
5076281b1b0dMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 1 file · ~1 modified
Description
Runtime: sp_poly_arr_get_hash handles SP_BUILTIN_SYM_POLY_HASH and STR_POLY_HASH
Previously only SP_BUILTIN_POLY_POLY_HASH was dispatched correctly; symbol- and string-keyed poly hashes fell through to sp_poly_arr_get which treated the hash as an array with integer index.
Fixes dig on poly arrays containing sym_poly_hash (e.g. [42, {foo: :bar}].dig(1, :foo))
Co-Authored-By: Claude Sonnet 4.6 [email protected]
Details
- Commit
- 5076281b1b0d
- Parent
- c221c3a2a192
lib/sp_runtime.hmodifiedView file
@@ -3821,6 +3821,10 @@
38213821
static sp_RbVal sp_poly_arr_get_hash(sp_RbVal a, mrb_int i) {38223822
if (a.tag == SP_TAG_OBJ && a.cls_id == SP_BUILTIN_POLY_POLY_HASH)38233823
return sp_PolyPolyHash_get((sp_PolyPolyHash*)a.v.p, sp_box_int(i));3824+
if (a.tag == SP_TAG_OBJ && a.cls_id == SP_BUILTIN_SYM_POLY_HASH)3825+
return sp_SymPolyHash_get((sp_SymPolyHash*)a.v.p, (sp_sym)i);3826+
if (a.tag == SP_TAG_OBJ && a.cls_id == SP_BUILTIN_STR_POLY_HASH)3827+
return sp_StrPolyHash_get((sp_StrPolyHash*)a.v.p, sp_sym_name_fn ? sp_sym_name_fn((sp_sym)i) : "");38243828
return sp_poly_arr_get(a, i);38253829
}38263830
static sp_RbVal sp_poly_arr_set_hash(sp_RbVal v, mrb_int idx, sp_RbVal val) {