Skip to content

Commit

Permalink
fixes #30927: add undef to printing of empty arrays (#30929)
Browse files Browse the repository at this point in the history
  • Loading branch information
simonbyrne authored and fredrikekre committed Feb 1, 2019
1 parent 0ec1727 commit 585feb0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion base/arrayshow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ _show_nonempty(::IO, ::AbstractVector, ::String) =
_show_nonempty(io::IO, X::AbstractArray{T,0} where T, prefix::String) = print_array(io, X)

# NOTE: it's not clear how this method could use the :typeinfo attribute
_show_empty(io::IO, X::Array{T}) where {T} = print(io, "Array{", T, "}(", join(size(X),','), ')')
_show_empty(io::IO, X::Array{T}) where {T} = print(io, "Array{", T, "}(undef,", join(size(X),','), ')')
_show_empty(io, X) = nothing # by default, we don't know this constructor

# typeinfo aware (necessarily)
Expand Down
4 changes: 4 additions & 0 deletions test/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1453,3 +1453,7 @@ end

# issue #30505
@test repr(Union{Tuple{Char}, Tuple{Char, Char}}[('a','b')]) == "Union{Tuple{Char}, Tuple{Char,Char}}[('a', 'b')]"

# issue #30927
Z = Array{Float64}(undef,0,0)
@test eval(Meta.parse(repr(Z))) == Z

0 comments on commit 585feb0

Please sign in to comment.