Commit d455e732
d455e732a502Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 2 files · ~2 modified
Description
Regexp#=== on a literal yields a match boolean
/re/ === str matches like /re/.match?(str), enabling case/when with regex conditions (which lower to ===).
Co-Authored-By: Claude Opus 4.8 [email protected]
Details
- Commit
- d455e732a502
- Parent
- be5c851ff948
src/analyze.cmodifiedView file
@@ -722,6 +722,11 @@
722722
}723723
}724724
725+
/* /re/ === str -> match boolean */726+
if (!strcmp(name, "===") && argc == 1 && recv >= 0 &&727+
nt_type(nt, recv) && !strcmp(nt_type(nt, recv), "RegularExpressionNode"))728+
return TY_BOOL;729+
725730
if ((!strcmp(name, "-@") || !strcmp(name, "+@")) && recv >= 0 && argc == 0)726731
return ty_is_numeric(rt) ? rt : TY_UNKNOWN;727732
if (!strcmp(name, "!")) return TY_BOOL;src/codegen.cmodifiedView file
Loading diff…