Skip to content

Fix String#index and #rindex for Char::REPLACEMENT#14937

Merged
straight-shoota merged 1 commit intocrystal-lang:masterfrom
HertzDevil:bug/string-index-replacement
Aug 25, 2024
Merged

Fix String#index and #rindex for Char::REPLACEMENT#14937
straight-shoota merged 1 commit intocrystal-lang:masterfrom
HertzDevil:bug/string-index-replacement

Conversation

@HertzDevil
Copy link
Contributor

If the string consists only of ASCII characters and invalid UTF-8 byte sequences, all the latter should correspond to Char::REPLACEMENT, and so #index and #rindex should detect them, but this was broken since #14461.

@HertzDevil HertzDevil added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib:text kind:regression Something that used to correctly work but no longer works labels Aug 23, 2024
Copy link
Member

@straight-shoota straight-shoota left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While at it, we could also add specs for searching for Char::REPLACEMENT in a string that is not single_byte_optimizable.

@straight-shoota straight-shoota added this to the 1.14.0 milestone Aug 23, 2024
@straight-shoota straight-shoota merged commit 0ad3e91 into crystal-lang:master Aug 25, 2024
@HertzDevil HertzDevil deleted the bug/string-index-replacement branch August 27, 2024 06:58
@straight-shoota straight-shoota modified the milestones: 1.14.0, 1.13.3 Sep 10, 2024
straight-shoota pushed a commit that referenced this pull request Sep 17, 2024
If the string consists only of ASCII characters and invalid UTF-8 byte sequences, all the latter should correspond to `Char::REPLACEMENT`, and so `#index` and `#rindex` should detect them, but this was broken since #14461.
@crysbot
Copy link
Collaborator

crysbot commented Sep 19, 2024

This pull request has been mentioned on Crystal Forum. There might be relevant details there:

https://forum.crystal-lang.org/t/crystal-1-13-3-is-released/7191/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind:bug A bug in the code. Does not apply to documentation, specs, etc. kind:regression Something that used to correctly work but no longer works topic:stdlib:text

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants