Skip to content

Commit

Permalink
fix #55389: type-unstable join
Browse files Browse the repository at this point in the history
  • Loading branch information
simeonschaub committed Aug 6, 2024
1 parent 0717a94 commit ac7dab0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion base/strings/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,8 @@ function join(io::IO, iterator, delim="")
end

function _join_preserve_annotations(iterator, args...)
if isconcretetype(eltype(iterator)) && !_isannotated(eltype(iterator)) && !any(_isannotated, args)
et = @default_eltype(iterator)
if isconcretetype(et) && !_isannotated(et) && !any(_isannotated, args)
sprint(join, iterator, args...)
else
io = AnnotatedIOBuffer()
Expand Down
5 changes: 5 additions & 0 deletions test/strings/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -344,3 +344,8 @@ end
@testset "`string` return types" begin
@test all(T -> T <: AbstractString, Base.return_types(string))
end

@testset "type stable `join` (#55389)" begin
itr = ("foo" for _ in 1:100)
@test Base.return_types(join, (typeof(itr),))[] == String
end

0 comments on commit ac7dab0

Please sign in to comment.