Commit 4f60232c
4f60232ce6baMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 2 files · ~2 modified
Description
Array#slice!(start, length) on int and str arrays
The sp_Array_slice_bang runtime helpers already exist and raise FrozenError on a frozen receiver; only the analyze return type (the removed subarray) and the codegen dispatch were missing. Wire up the two-argument start/length form.
Co-Authored-By: Claude Opus 4.8 [email protected]
Details
- Commit
- 4f60232ce6ba
- Parent
- 2d7c57ed484b
src/analyze.cmodifiedView file
@@ -566,6 +566,7 @@
566566
if ((!strcmp(name, "delete_at") || !strcmp(name, "delete")) && argc == 1)567567
return ty_array_elem(rt);568568
if (!strcmp(name, "shift") && argc == 0) return ty_array_elem(rt);569+
if (!strcmp(name, "slice!") && argc == 2) return rt; /* removed subarray */569570
if (!strcmp(name, "[]=")) return ty_array_elem(rt);570571
if ((!strcmp(name, "assoc") || !strcmp(name, "rassoc")) && rt == TY_POLY_ARRAY)571572
return TY_POLY_ARRAY; /* the matching sub-array, or nil (NULL ptr) */src/codegen.cmodifiedView file
Loading diff…