Commit 53bd7c7a
53bd7c7aa76aMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 2 files · ~2 modified
Description
fix: Hash#to_h identity dispatch for all hash variants
`opts.to_h` is identity on a Hash receiver (the call is the NamedTuple→Hash bridge from view_helpers — opts is already a Hash at runtime). Pre-fix the call fell through to "cannot resolve call to 'to_h' on sym_*_hash" and emitted 0.
Two-line fix in each phase:
- analyze infer_call_type: `to_h` on a hash-typed recv returns the recv's type unchanged
- codegen compile_hash_method_expr: `to_h` on a hash-typed recv returns rc directly
Closes the remaining sym_str_hash / sym_poly_hash to_h warnings; archive 36 → 33.
Refs #450
Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]
Details
- Commit
- 53bd7c7aa76a
- Parent
- bb1ba86ff3d4
spinel_analyze.rbmodifiedView file
@@ -4054,6 +4054,16 @@
40544054
end40554055
end40564056
end4057+
# `to_h` on a Hash variant is identity. Surface so the caller4058+
# gets the recv's exact type rather than an unresolved fallback.4059+
if mname == "to_h"4060+
if recv >= 04061+
rt = infer_type(recv)4062+
if is_hash_type(rt) == 14063+
return rt4064+
end4065+
end4066+
end40574067
if mname == "fdiv"40584068
return "float"40594069
endspinel_codegen.rbmodifiedView file
Loading diff…