diff --git a/base/char.jl b/base/char.jl index 95c3d624b5c1a..43eb92f0470d1 100644 --- a/base/char.jl +++ b/base/char.jl @@ -187,6 +187,7 @@ size(c::AbstractChar,d) = convert(Int, d) < 1 ? throw(BoundsError()) : 1 ndims(c::AbstractChar) = 0 ndims(::Type{<:AbstractChar}) = 0 length(c::AbstractChar) = 1 +IteratorSize(::Type{Char}) = HasShape{0}() firstindex(c::AbstractChar) = 1 lastindex(c::AbstractChar) = 1 getindex(c::AbstractChar) = c diff --git a/test/char.jl b/test/char.jl index e5fca3f6807d7..3a2c54b76d3bb 100644 --- a/test/char.jl +++ b/test/char.jl @@ -286,3 +286,7 @@ end @test reinterpret(UInt32, reinterpret(Char, u)) === u end end + +@testset "broadcasting of Char" begin + @test identity.('a') == 'a' +end