Commit e99ca666
e99ca66646a4Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 7 months ago · 2 files · ~2 modified
Description
fix(codegen): infer float_array.sum as float, not int
Follow-up to db8307f (PR #24). The dispatch and runtime helper added
there emit sp_FloatArray_sum correctly, but infer_method_name_type
still returned "int" for sum regardless of receiver, so call sites
wrapped the result in (long long) and truncated non-integer-valued
sums (e.g. [1.5, 2.5, 0.5].sum printed 4 instead of 4.5).
Mirror the existing min/max shape: when recv is float_array,
return "float". Other receivers keep the int default.
Extend test/bm_float_array.rb with [1.5, 2.5, 0.5].sum (= 4.5,
deliberately non-integer-valued so the truncation regression would
fail loudly if reintroduced).
Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]
Details
- Commit
- e99ca66646a4
- Parent
- d8e1d0295350
spinel_codegen.rbmodifiedView file
return "int" end if mname == "sum" if recv >= 0 rt = infer_type(recv) if rt == "float_array" return "float" end end return "int" end if mname == "reverse"test/bm_float_array.rbmodifiedView file
Loading diff…