JuliaLang / julia

The Julia Programming Language
https://julialang.org/
MIT License
45.39k stars 5.45k forks source link

`strings/annotated` test relies on that StyledStrings have been loaded #54561

Open KristofferC opened 3 months ago

KristofferC commented 3 months ago

This is a reduction of a test in test/strings/annotated.jl that avoids loading StyledStrings (which now gets loaded when loading Test.jl):

str1 = Base.AnnotatedString("test", [(1:4, :label => 5)])
str2 = Base.AnnotatedString("case", [(2:3, :label => "oomph")])
@assert join([str1, str1], ' ') ==
    Base.AnnotatedString("test test",
                 [(1:4, :label => 5),
                  (6:9, :label => 5)])

Running this fails with:

ERROR: LoadError: AssertionError: join([str1, str1], ' ') == Base.AnnotatedString("test test", [(1:4, :label => 5), (6:9, :label => 5)])

However, if we add

using StyledStrings

to the top, the assert does not fire.

The reason for this is type piracy in StyledStrings: https://github.com/JuliaLang/StyledStrings.jl/issues/61.

It is weird that things like join on base types give different results depending on if an stdlib has been (transitively) loaded. The rendering of StyledStrings should probably move to Base to fix this.

tecosaur commented 3 months ago

@KristofferC to be clearer about what the plan/hope is here, are you thinking we ship 1.11 as-is, then move the code around in 1.12?