Commit edc12fed
edc12fed179cMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 7 months ago · 1 file · ~1 modified
Description
fix: infer ForNode loop variable type from collection element type
for-in loop variables now correctly infer their type from the collection: str_array → string, float_array → float, ptr_array → element type. Previously always defaulted to int regardless of the collection type.
Co-Authored-By: Claude Opus 4.6 (1M context) [email protected]
Details
- Commit
- edc12fed179c
- Parent
- ae3afb5c9a33
spinel_codegen.rbmodifiedView file
@@ -9066,8 +9066,21 @@
90669066
lname = @nd_name[tgt]90679067
if not_in(lname, names) == 190689068
if not_in(lname, params) == 19069+
# Infer element type from collection9070+
elem_type = "int"9071+
coll = @nd_collection[nid]9072+
if coll >= 09073+
ct = infer_type(coll)9074+
if ct == "str_array"9075+
elem_type = "string"9076+
elsif ct == "float_array"9077+
elem_type = "float"9078+
elsif is_ptr_array_type(ct) == 19079+
elem_type = ptr_array_elem_type(ct)9080+
end9081+
end90699082
names.push(lname)9070-
types.push("int")9083+
types.push(elem_type)90719084
end90729085
end90739086
end