diff --git a/base/show.jl b/base/show.jl index 217b22ab39ef85..e40b59c6af7640 100644 --- a/base/show.jl +++ b/base/show.jl @@ -3007,7 +3007,9 @@ function dump(io::IOContext, x::DataType, n::Int, indent) fieldtypes = datatype_fieldtypes(x) for idx in 1:length(fields) println(io) - print(io, indent, " ", fields[idx]) + print(io, indent, " ") + isconst(x, idx) && print(io, "const ") + print(io, fields[idx]) if isassigned(fieldtypes, idx) print(io, "::") print(tvar_io, fieldtypes[idx]) diff --git a/test/show.jl b/test/show.jl index 064ae76b6fe1ff..7aa0d5adbb0c5f 100644 --- a/test/show.jl +++ b/test/show.jl @@ -1263,7 +1263,7 @@ let repr = sprint(dump, :(x = 1)) @test repr == "Expr\n head: Symbol =\n args: Array{Any}((2,))\n 1: Symbol x\n 2: $Int 1\n" end let repr = sprint(dump, Pair{String,Int64}) - @test repr == "Pair{String, Int64} <: Any\n first::String\n second::Int64\n" + @test repr == "Pair{String, Int64} <: Any\n const first::String\n const second::Int64\n" end let repr = sprint(dump, Tuple) @test repr == "Tuple <: Any\n"