diff --git a/src/types.jl b/src/types.jl index 42cdbc1f0..03b6c311c 100644 --- a/src/types.jl +++ b/src/types.jl @@ -845,6 +845,8 @@ function show_term(io::IO, t) show_pow(io, args) elseif f === (getindex) show_ref(io, f, args) + elseif f === (identity) && !issym(args[1]) && !istree(args[1]) + show(io, args[1]) else show_call(io, f, args) end diff --git a/test/code.jl b/test/code.jl index 31290e67e..5a10ca0c2 100644 --- a/test/code.jl +++ b/test/code.jl @@ -190,4 +190,16 @@ test_repr(a, b) = @test repr(Base.remove_linenums!(a)) == repr(Base.remove_linen @test f(1) == 1 @test f(2) == 2 end + + let + io = IOBuffer() + twoπ = Base.Irrational{:twoπ}() + for q ∈ Base.Irrational[Base.MathConstants.catalan, Base.MathConstants.γ, π, Base.MathConstants.φ, ℯ, twoπ] + Base.show(io, q) + s1 = String(take!(io)) + SymbolicUtils.show_term(io, SymbolicUtils.Term(identity, [q])) + s2 = String(take!(io)) + @test s1 == s2 + end + end end