Commit d7b8668e
d7b8668e2803Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 2 files · ~2 modified
Description
String#gsub/sub/split/scan with a regex-literal argument
A string method whose first argument is a /re/ literal routes to the engine: gsub/sub -> sp_re_gsub/sp_re_sub, split -> sp_re_split, and scan -> sp_re_scan (typed String / String[]). scan is restricted to capture-free patterns since a capturing scan returns nested arrays that the str_array path can't represent; those fall through for now.
Co-Authored-By: Claude Opus 4.8 (1M context) [email protected]
Details
- Commit
- d7b8668e2803
- Parent
- 13c7b7e1c797
src/analyze.cmodifiedView file
@@ -585,7 +585,7 @@
585585
!strcmp(name, "oct") || !strcmp(name, "ord") || !strcmp(name, "casecmp")) return TY_INT;586586
if (!strcmp(name, "casecmp?")) return TY_BOOL;587587
if (!strcmp(name, "to_f")) return TY_FLOAT;588-
if (!strcmp(name, "split") || !strcmp(name, "lines")) return TY_STR_ARRAY;588+
if (!strcmp(name, "split") || !strcmp(name, "lines") || !strcmp(name, "scan")) return TY_STR_ARRAY;589589
if (!strcmp(name, "each_char") || !strcmp(name, "each_line") || !strcmp(name, "each_byte")) return TY_STRING;590590
if (!strcmp(name, "bytes")) return TY_INT_ARRAY;591591
if (!strcmp(name, "gsub") || !strcmp(name, "sub") || !strcmp(name, "tr") ||src/codegen.cmodifiedView file
Loading diff…