Commit 990eca08

990eca08cf9eMerged

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

Description

String#slice and beginless/endless range slicing

String#slice aliases [] (range, start+len, single index). Beginless/ endless string ranges (s[1..], s[..2]) clamp to 0 / length.

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

Details

Commit
990eca08cf9e
Parent
5f29c311a19f

src/analyze.cmodifiedView file

@@ -373,7 +373,7 @@
373373 !strcmp(name, "strip") || !strcmp(name, "lstrip") ||
374374 !strcmp(name, "rstrip") || !strcmp(name, "chomp") ||
375375 !strcmp(name, "chop") || !strcmp(name, "chr")) return TY_STRING;
376- if (!strcmp(name, "[]")) return TY_STRING;
376+ if (!strcmp(name, "[]") || !strcmp(name, "slice")) return TY_STRING;
377377 if (!strcmp(name, "index") || !strcmp(name, "to_i")) return TY_INT;
378378 if (!strcmp(name, "to_f")) return TY_FLOAT;
379379 if (!strcmp(name, "split") || !strcmp(name, "lines")) return TY_STR_ARRAY;