Commit a65b5546

a65b55468b08Merged

NHH <[email protected]> · 5 months ago · 3 files · +2 added · ~1 modified

Description

analyze: fix Hash#invert return type in infer_method_name_type fallback

The fallback handler in infer_method_name_type always returned "str_str_hash" for invert, regardless of the receiver hash type. While infer_operator_type normally handles invert first with correct type dispatch (str_str_hash→str_str_hash, others→poly_poly_hash), the fallback should be consistent. Now it inspects the receiver type and returns str_str_hash only for str_str_hash and int_str_hash; all other hash types return poly_poly_hash.

Details

Commit
a65b55468b08
Parent
65aacf420ed1

spinel_analyze.rbmodifiedView file

@@ -5277,7 +5277,16 @@
52775277 return "int_array"
52785278 end
52795279 if mname == "invert"
5280- return "str_str_hash"
5280+ # Hash#invert -- fallback; normally handled in infer_operator_type.
5281+ if recv >= 0
5282+ rt_inv = infer_type(recv)
5283+ if rt_inv == "str_str_hash" || rt_inv == "int_str_hash"
5284+ return "str_str_hash"
5285+ end
5286+ if is_hash_type(rt_inv) == 1
5287+ return "poly_poly_hash"
5288+ end
5289+ end
52815290 end
52825291 if mname == "push" || mname == "append"
52835292 if recv >= 0