Commit ee5107cf
ee5107cff216Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 2 files · ~2 modified
Description
Add Array#product, #repeated_combination, #fetch, one?(v), zip(poly), bsearch/find_index fixes
- Array#product(b) for typed and poly arrays: cartesian product → PolyArray of pairs
- Array#repeated_combination(k) for IntArray: returns PolyArray of IntArrays
- Array#fetch(i) and fetch(i,default) for typed and poly arrays with bounds check
- one?(v)/any?(v)/none?(v)/count(v) with value arg for typed and poly arrays
- Array#zip on PolyArray receiver → PolyArray of PolyArrays
- Fix bsearch and find_index_block preamble-inside-declaration bug (use Buf for recv)
- Fix find_index block result: box mrb_int sentinel as sp_RbVal (nil or int)
- Fix each_index block param: box index as sp_RbVal when local is TY_POLY
- Fix empty-array one?(v)/count(v) constant-fold for argc==1 case
- Fixes bundle_tiny_array (ERR → PASS)
Co-Authored-By: Claude Sonnet 4.6 [email protected]
Details
- Commit
- ee5107cff216
- Parent
- 03eb2769b6aa
src/analyze.cmodifiedView file
@@ -1322,6 +1322,7 @@
13221322
return ty_array_elem(rt);13231323
}13241324
if (!strcmp(name, "at") && argc == 1) return ty_array_elem(rt); /* like [i] */1325+
if (!strcmp(name, "fetch") && (argc == 1 || argc == 2)) return ty_array_elem(rt);13251326
if (!strcmp(name, "dig") && argc >= 1) {13261327
if (argc == 1) return ty_array_elem(rt);13271328
return TY_POLY;@@ -1439,6 +1440,8 @@
14391440
!strcmp(name, "replace") ||14401441
!strcmp(name, "values_at")) return rt;14411442
if (!strcmp(name, "zip") && block < 0) return TY_POLY_ARRAY;1443+
if (!strcmp(name, "product") && argc == 1) return TY_POLY_ARRAY;1444+
if (!strcmp(name, "repeated_combination") && argc == 1) return TY_POLY_ARRAY;14421445
if (!strcmp(name, "frozen?")) return TY_BOOL;14431446
if ((!strcmp(name, "delete_at") || !strcmp(name, "delete")) && argc == 1)14441447
return ty_array_elem(rt);src/codegen.cmodifiedView file
Loading diff…