Commit 2e186d18
2e186d18c766Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 4 files · +2 added · ~2 modified
Description
Preserve Float values stored in a Hash
A hash literal with Float values had no dedicated typed variant, so infer_hash_val_type fell through to the str_int_hash default and the fractional part was truncated to mrb_int on read ({"k"=>52.9} read back as 52). Route float-valued literals to poly storage (str_poly_hash / sym_poly_hash / poly_poly_hash by key shape) so each slot keeps its own tag, mirroring the existing poly/symbol-value arms. The incremental empty-hash-then-[]= path already promoted floats to poly via scan_locals; this aligns the literal path with it.
Fixes #1258
Co-Authored-By: Claude Opus 4.8 [email protected]
Details
- Commit
- 2e186d18c766
- Parent
- 82f11332444d
spinel_analyze.rbmodifiedView file
end return "str_poly_hash" end # Float values have no dedicated typed-hash variant; route them # through poly storage so each slot keeps its own tag rather than # falling through to the str_int_hash default (which truncates the # float to mrb_int on read). if first_vt == "float" @needs_rb_value = 1 if all_sym_keys == 1 return "sym_poly_hash" end if all_int_keys == 1 return "poly_poly_hash" end return "str_poly_hash" end # Inner hash/array values need a poly outer so each pointer # can carry its own cls_id through SP_TAG_OBJ. if is_hash_type(first_vt) == 1 || is_array_type(first_vt) == 1spinel_codegen.rbmodifiedView file
Loading diff…
test/hash_float_value_preserved.rbaddedView file
Loading diff…
test/hash_float_value_preserved.rb.expectedaddedView file
Loading diff…