Skip to content

Commit

Permalink
Change TypeVars in UnionAlls to print as var"" syntax (#34888)
Browse files Browse the repository at this point in the history
This changes unnamed type variables to print as valid syntax, via the
`var""` printing macro.

For example, before this commit, `Vector{<:Bool}` printed as a
non-syntactic string:
```julia
julia> Vector{<:Bool}
Array{#s16,1} where #s16<:Bool
```

And now it prints as a valid, syntactic expression:
```julia
julia> Vector{<:Bool}
Array{var"#s46",1} where var"#s46"<:Bool
```
  • Loading branch information
NHDaly authored and KristofferC committed Apr 11, 2020
1 parent a6b237c commit 753932b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions base/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1817,16 +1817,16 @@ function show(io::IO, tv::TypeVar)
lb, ub = tv.lb, tv.ub
if !in_env && lb !== Bottom
if ub === Any
write(io, tv.name)
show_unquoted(io, tv.name)
print(io, ">:")
show_bound(io, lb)
else
show_bound(io, lb)
print(io, "<:")
write(io, tv.name)
show_unquoted(io, tv.name)
end
else
write(io, tv.name)
show_unquoted(io, tv.name)
end
if !in_env && ub !== Any
print(io, "<:")
Expand Down

0 comments on commit 753932b

Please sign in to comment.