-
-
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
AnnotatedString
s are not repr-eval-able.
#54193
Comments
I think the thing that makes Perhaps such uses of the 2-arg show should be changed to 3-arg show and the 2-arg NB: |
Ok, one path forwards is to implement a specialised I'd be keen to hear thoughts on how to best resolve this. |
I don't see "2-arg show is the more concise version" in the docs. That happens to be the case because parseable Julia code is often more concise than the human-readable version (e.g. I think this would be reasonable, and an improvement over showing "abc" in both cases: julia> show(stdout, Day(1))
Day(1)
julia> show(stdout, MIME("text/plain"), Day(1))
1 day
julia> show(stdout, Base.AnnotatedString("abc", [(1:2, :value => π)]))
Base.AnnotatedString("abc", [(1:2, :value => π)])
julia> show(stdout, MIME("text/plain"), Base.AnnotatedString("abc", [(1:2, :value => π)]))
"abc" |
I took that implication from
but now I've got the second opinion I've asked for, I'll happily PR function show(io::IO, astr::A) where {A <: AnnotatedString}
show(io, A)
print(io, '(')
show(io, astr.string)
print(io, ", ")
show(io, annotations(astr))
print(io, ')')
end 🙂 |
Ah, I missed that word. But yes, I still think that reprable is more important than concise in this case. |
Cool, I'll go ahead with the PR then. |
eval(Meta.parse(repr(x))) == x
should hold whenever possible. It does not hold forAnnotatedString
s.An example of a symptom of this problem that came up when testing #53715 is that
@test
equality hints are misleading forAnotatedString
s with annotation mismatches:Adding a special case that notes "annotation mismatch" would be an improvement, but I'm guessing
repr
is the root cause.cc @tecosaur
The text was updated successfully, but these errors were encountered: