-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Substrings mask annotations #53042
Comments
We could patch up the One way to approach it is to try to make AnnotatedString as closed as possible under various operations, e.g. have indexing return an AnnotatedString instead of a SubString. Possibly an |
One bug here is that |
Apologies that I've been rather poor at responding to this; I've found this problem somewhat tricky. For starters, the behaviour Lilith demonstrates is clearly erroneous, and Jeff's idea of using However, I'm concerned that it will cause its own problems around code that uses parametric substring types. Currently calling I haven't had any nice ideas on how to resolve this tension, beyond just going for the whack-a-mole |
From the comments above, I currently don't have a better idea than implementing a specialised equality methods for If anybody has a better thought (cc: @JeffBezanson), please do let me know. If I don't hear anything in the near future I'll make a PR doing this. We can always make the solution better/nicer, but making the test case Lilith shows not broken at least seems like a clear improvement even if the mechanism isn't ideal. |
SGTM. Fixing bugs is ususally a good first step :) |
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.
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)
This is (arguably) a bug in the new StyledStrings library but I don't see this being release blocking. |
I believe the fix is in 1.11-beta2 anyway? |
All I know is that this issue is still open. Feel free to close if it has been addressed. |
The least-bad idea I've had so far for fixing JuliaLang#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.
SubString{Base.AnnotatedString{String}}
(produced byannotated_string[1:2]
) is an un-annotated string in the sense that it compares equal to strings with the same content without annotations and unequal to strings with annotations.The text was updated successfully, but these errors were encountered: