Commit 120b8f23

120b8f237d16Merged

Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 3 files · +2 added · ~1 modified

Description

fix(analyze): str_int_hash → str_str_hash merge in method bodies (#443)

Sibling to #437. The refine_method_body_locals merge had no rule to upgrade str_int_hash → str_str_hash when pass 2 correctly resolved the value as string. Pass 1 fell back to vt=int because the value's source local (e.g. `pb` from `pb = b.split("/")`) wasn't declared yet; promote_empty_hash_for("string", "int") returned str_int_hash. Pass 2 with pb declared as str_array resolved pb[i] as string and picked str_str_hash, but the merge dropped the upgrade.

Add the missing rule, symmetric to the int_str_hash → str_str_hash rule added in 57d9731 (#437 follow-up) and the refine_locals_multi_pass_full str_int_hash → str_str_hash rule at line 20142.

Closes #443

Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]

Details

Commit
120b8f237d16
Parent
d53dd0271e05

spinel_analyze.rbmodifiedView file

@@ -20530,6 +20530,15 @@
2053020530 elsif ltypes[k] == "int_str_hash" && (ltypes2[j] == "str_str_hash" || ltypes2[j] == "sym_str_hash" || ltypes2[j] == "str_int_hash" || ltypes2[j] == "sym_int_hash")
2053120531 ltypes[k] = ltypes2[j]
2053220532 set_var_type(lnames[k], ltypes2[j])
20533+ # Symmetric: pass 1 saw `vt=int` because the value's source
20534+ # local (e.g. `pb` from `pb = b.split("/")`) wasn't declared
20535+ # yet, leaving the hash at str_int_hash. Pass 2 with `pb`
20536+ # declared as str_array correctly resolves pb[i] as string and
20537+ # picks str_str_hash. Mirrors the rule in
20538+ # refine_locals_multi_pass_full at line 20142.
20539+ elsif ltypes[k] == "str_int_hash" && ltypes2[j] == "str_str_hash"
20540+ ltypes[k] = ltypes2[j]
20541+ set_var_type(lnames[k], ltypes2[j])
2053320542 end
2053420543 end
2053520544 k = k + 1