Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prints symbols in Tuple{:sym} type with colons #42999

Merged
merged 4 commits into from
Nov 10, 2021

Conversation

inkydragon
Copy link
Member

@inkydragon inkydragon commented Nov 8, 2021

fix #42931

old master

julia> versioninfo()
Julia Version 1.8.0-DEV.801
Commit 59aa3ed324 (2021-10-22 13:27 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i5-9400F CPU @ 2.90GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.1 (ORCJIT, skylake)

julia> repr(NTuple{4, :sym})
"NTuple{4, sym}"

julia> repr(NTuple{3, :sym})
"Tuple{sym, sym, sym}"

julia> repr(Tuple{:A, :B})
"Tuple{A, B}"

julia> repr(Tuple{:A})
"Tuple{A}"

julia> repr(Tuple{})
"Tuple{}"

With proposed improvements:

julia> versioninfo()
Julia Version 1.8.0-DEV.881
Commit cd3eba867c (2021-11-08 11:27 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i5-9400F CPU @ 2.90GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.1 (ORCJIT, skylake)

julia> repr(NTuple{4, :sym})
"NTuple{4, :sym}"

julia> repr(NTuple{3, :sym})
"Tuple{:sym, :sym, :sym}"

julia> repr(Tuple{:A, :B})
"Tuple{:A, :B}"

julia> repr(Tuple{:A})
"Tuple{:A}"

julia> repr(Tuple{})
"Tuple{}"

base/show.jl Outdated
@@ -993,10 +993,10 @@ function show_datatype(io::IO, @nospecialize(x::DataType), wheres::Vector=TypeVa
# Print homogeneous tuples with more than 3 elements compactly as NTuple{N, T}
if istuple
if n > 3 && all(@nospecialize(i) -> (parameters[1] === i), parameters)
print(io, "NTuple{", n, ", ", parameters[1], "}")
print(io, "NTuple{", n, ", ", repr(parameters[1]), "}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should call show(io, parameters[1]) (same below) so that the context information in io can be used.

@vtjnash vtjnash merged commit 6fbfc4f into JuliaLang:master Nov 10, 2021
KristofferC pushed a commit that referenced this pull request Nov 13, 2021
Use `show` instead of `print` or `join`.

(cherry picked from commit 6fbfc4f)
daviehh pushed a commit to daviehh/julia that referenced this pull request Nov 16, 2021
Use `show` instead of `print` or `join`.

(cherry picked from commit 6fbfc4f)
LilithHafner pushed a commit to LilithHafner/julia that referenced this pull request Feb 22, 2022
Use `show` instead of `print` or `join`.
LilithHafner pushed a commit to LilithHafner/julia that referenced this pull request Mar 8, 2022
Use `show` instead of `print` or `join`.
@inkydragon inkydragon deleted the Tuple-sym branch April 29, 2022 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Show Tuple{:A,:B} displays as Tuple{A,B} on 1.7
4 participants