Commit f7e20839

f7e208397dffMerged

Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 2 files · ~2 modified

Description

Range equality/eql?/exclude_end?/minmax/step/each, and Array#to_a

Range ==/!=/eql? via sp_range_eq (range vs non-range -> false), step(n) materializes the stepped int array, each without a block materializes to_a, plus exclude_end? and minmax. Typed arrays gain to_a/to_ary/ entries (identity).

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

Details

Commit
f7e208397dff
Parent
3bcdcf6a4c5f

src/analyze.cmodifiedView file

@@ -327,9 +327,12 @@
327327
328328 /* range receiver methods */
329329 if (recv >= 0 && rt == TY_RANGE) {
330- if (!strcmp(name, "to_a")) return TY_INT_ARRAY;
330+ if (!strcmp(name, "to_a") || !strcmp(name, "minmax")) return TY_INT_ARRAY;
331331 if (!strcmp(name, "include?") || !strcmp(name, "member?") ||
332- !strcmp(name, "cover?")) return TY_BOOL;
332+ !strcmp(name, "cover?") || !strcmp(name, "exclude_end?") ||
333+ !strcmp(name, "eql?") || !strcmp(name, "==") || !strcmp(name, "!=")) return TY_BOOL;
334+ if (!strcmp(name, "step")) return TY_INT_ARRAY;
335+ if (!strcmp(name, "each") && nt_ref(nt, id, "block") < 0) return TY_INT_ARRAY;
333336 if (!strcmp(name, "sum") || !strcmp(name, "min") || !strcmp(name, "max") ||
334337 !strcmp(name, "first") || !strcmp(name, "last") ||
335338 !strcmp(name, "size") || !strcmp(name, "count") ||