Commit 2e7cb8b8
2e7cb8b89001Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 4 files · +2 added · ~2 modified
Description
fix(codegen,analyze): Array#values_at for int / sym / str arrays (#742 partial)
[:a, :b, :c].values_at(0, 2) used to fall through to the
unresolved-call warning ("cannot resolve call to 'values_at' on
sym_array"). Implement values_at for int_array (covers sym_array
since they share the IntArray runtime), and str_array.
The codegen emits inline -- build a fresh typed array, push the result of get(arr, idx) for each index arg in order. Variadic arity is handled by walking the args list; no runtime helper needed since the unroll is fixed per call site.
analyze.rb's values_at arm returns the recv's array type so chained ops keep the right shape.
#742 also lists combination and permutation; those are deferred (they need new typed-tuple shapes for the result, not a same-shape return). values_at was the simplest of the three.
Test: test/values_at.rb covers sym, int, str variants plus repeated index lookup.
476 tests pass; optcarrot checksum 59662.
Refs #742
Co-Authored-By: Claude Opus 4.7 [email protected]
Details
- Commit
- 2e7cb8b89001
- Parent
- a0c43409025a
spinel_analyze.rbmodifiedView file
end end end if mname == "values_at" # `arr.values_at(...)` returns an array of the same element # type. Issue #742. if recv >= 0 rt_va = infer_type(recv) if is_array_type(rt_va) == 1 return rt_va end end end if mname == "<<" if recv >= 0 if lt == "mutable_str"spinel_codegen.rbmodifiedView file
Loading diff…
test/values_at.rbaddedView file
Loading diff…
test/values_at.rb.expectedaddedView file
Loading diff…