Actions
Bug #19763
closedInconsistent error message for String#index vs String#rindex
Description
String#index
and String#rindex
yields different error messages when used with a Regexp
argument:
'abc'.force_encoding("ISO-2022-JP").index(/わ/)
Prints: incompatible character encodings: ISO-2022-JP and UTF-8 (Encoding::CompatibilityError)
'abc'.force_encoding("ISO-2022-JP").rindex(/わ/)
Prints: incompatible encoding regexp match (UTF-8 regexp with ISO-2022-JP string) (Encoding::CompatibilityError)
Looking at a few other use cases (eg String#byteindex
, String#byterindex
) Ruby seems to use the message incompatible encoding regexp match
when encoding is checked between a String and a Regexp instance. Is this a bug for String#index
?
Updated by nobu (Nobuyoshi Nakada) over 1 year ago
Updated by nobu (Nobuyoshi Nakada) over 1 year ago
- Status changed from Open to Closed
Applied in changeset git|e2257831ab20915b839eeaff79c6ec45b498de77.
[Bug #19763] Raise same message exception for regexp
Actions
Like0
Like1Like0