Skip to content

Commit ac7dab0

Browse files
committed
fix #55389: type-unstable join
1 parent 0717a94 commit ac7dab0

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

base/strings/io.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,8 @@ function join(io::IO, iterator, delim="")
354354
end
355355

356356
function _join_preserve_annotations(iterator, args...)
357-
if isconcretetype(eltype(iterator)) && !_isannotated(eltype(iterator)) && !any(_isannotated, args)
357+
et = @default_eltype(iterator)
358+
if isconcretetype(et) && !_isannotated(et) && !any(_isannotated, args)
358359
sprint(join, iterator, args...)
359360
else
360361
io = AnnotatedIOBuffer()

test/strings/io.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,3 +344,8 @@ end
344344
@testset "`string` return types" begin
345345
@test all(T -> T <: AbstractString, Base.return_types(string))
346346
end
347+
348+
@testset "type stable `join` (#55389)" begin
349+
itr = ("foo" for _ in 1:100)
350+
@test Base.return_types(join, (typeof(itr),))[] == String
351+
end

0 commit comments

Comments
 (0)