Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specialised substring equality for annotated strs #54302

Merged
merged 1 commit into from May 2, 2024

Conversation

tecosaur
Copy link
Contributor

The least-bad idea I've had so far for fixing #53042.

I figure this fixes the bug raised there, and we can always switch to a clearly-better solution if one appears.

See the commit message for details.

@tecosaur tecosaur added domain:strings "Strings!" backport 1.11 Change should be backported to release-1.11 labels Apr 29, 2024
The fact that only a string without annotations is equal to a
non-annotated string (in order to preserve the transitivity of
equality), makes the generic fallback methods for string comparison
insufficient.

As such, ==(::AnnoatedString, ::AbstractString) is implemented in
annotated.jl, but this issue re-appears when dealing with substrings.

The obvious solution is to just implement a specialised method for
substrings. This does seem potentially a bit whack-a-mole, but I'm
worried that cleverer solutions might come with subtle issues of their
own. For now, let's try the simple and obvious solution, and improve it
later if we can work out a nicer way of handling this issue in general.
@fingolfin fingolfin merged commit 185f058 into JuliaLang:master May 2, 2024
7 checks passed
@tecosaur tecosaur deleted the annot-substring-compison branch May 2, 2024 09:41
KristofferC pushed a commit that referenced this pull request May 6, 2024
The least-bad idea I've had so far for fixing #53042.

I figure this fixes the bug raised there, and we can always switch to a
clearly-better solution if one appears.

The fact that only a string without annotations is equal to a
non-annotated string (in order to preserve the transitivity of
equality), makes the generic fallback methods for string comparison
insufficient.

As such, ==(::AnnoatedString, ::AbstractString) is implemented in
annotated.jl, but this issue re-appears when dealing with substrings.

The obvious solution is to just implement a specialised method for
substrings. This does seem potentially a bit whack-a-mole, but I'm
worried that cleverer solutions might come with subtle issues of their
own. For now, let's try the simple and obvious solution, and improve it
later if we can work out a nicer way of handling this issue in general.

(cherry picked from commit 185f058)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 1.11 Change should be backported to release-1.11 domain:strings "Strings!"
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants