Commit d903820a
d903820a0c43Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 3 files · +2 added · ~1 modified
Description
fix(codegen): sym_X_hash -> sym_poly_hash conversion at call boundary
After the #676 kwargs-bind path and #685 hash-variant cross-merge fixes, a Symbol-keyed Hash literal flowing into a sym_poly_hash- typed callee param fell through with a raw sp_SymStrHash * cast. The receiving callee read sp_RbVal values from what was actually a const char * layout; reads returned garbage and complex flows segfaulted.
Extend hash_variant_convert with dst_t == "sym_poly_hash" arms:
- sym_int_hash -> sp_SymIntHash_to_sym_poly (helper already exists)
- sym_str_hash -> sp_SymStrHash_to_sym_poly (ditto)
compile_expr_for_expected_type's hash-to-hash arm already routes through hash_variant_convert; the missing piece was the destination direction, not the entry point.
Tests: default 461/0/0, promote 461/0/0, optcarrot checksum 59662. New regression in test/hash_variant_call_boundary_sym.rb covers the literal -> sym_poly_hash and the merge-then-pass shapes.
Closes #690
Co-Authored-By: Claude Opus 4.7 [email protected]
Details
- Commit
- d903820a0c43
- Parent
- a9c8fa520acc
spinel_codegen.rbmodifiedView file
return "sp_StrPolyHash_from_sym_poly_hash(" + src_var + ")" end end if dst_t == "sym_poly_hash" if src_t == "sym_int_hash" @needs_sym_poly_hash = 1 @needs_sym_int_hash = 1 @needs_rb_value = 1 return "sp_SymIntHash_to_sym_poly(" + src_var + ")" end if src_t == "sym_str_hash" @needs_sym_poly_hash = 1 @needs_sym_str_hash = 1 @needs_rb_value = 1 return "sp_SymStrHash_to_sym_poly(" + src_var + ")" end end "" endtest/hash_variant_call_boundary_sym.rbaddedView file
Loading diff…
test/hash_variant_call_boundary_sym.rb.expectedaddedView file
Loading diff…