Skip to content

Commit 67183f5

Browse files
committed
add missing printing of where vars in ambiguity suggestions
1 parent d3250fe commit 67183f5

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

base/show.jl

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1502,8 +1502,15 @@ function show_tuple_as_call(io::IO, name::Symbol, sig::Type)
15021502
printstyled(io, name, "(...)", color=color)
15031503
return
15041504
end
1505-
sig = unwrap_unionall(sig).parameters
1506-
with_output_color(color, io) do io
1505+
tv = Any[]
1506+
env_io = io
1507+
while isa(sig, UnionAll)
1508+
push!(tv, sig.var)
1509+
env_io = IOContext(env_io, :unionall_env => sig.var)
1510+
sig = sig.body
1511+
end
1512+
sig = sig.parameters
1513+
with_output_color(color, env_io) do io
15071514
ft = sig[1]
15081515
uw = unwrap_unionall(ft)
15091516
if ft <: Function && isa(uw,DataType) && isempty(uw.parameters) &&
@@ -1523,9 +1530,10 @@ function show_tuple_as_call(io::IO, name::Symbol, sig::Type)
15231530
for i = 2:length(sig) # fixme (iter): `eachindex` with offset?
15241531
first || print(io, ", ")
15251532
first = false
1526-
print(io, "::", sig[i])
1533+
print(env_io, "::", sig[i])
15271534
end
15281535
printstyled(io, ")", color=print_style)
1536+
show_method_params(io, tv)
15291537
nothing
15301538
end
15311539

test/ambiguous.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,19 @@ let err = try
6767
@test lines[6] == " ambig(::Integer, ::Integer)"
6868
end
6969

70+
ambig_with_bounds(x, ::Int, ::T) where {T<:Integer,S} = 0
71+
ambig_with_bounds(::Int, x, ::T) where {T<:Integer,S} = 1
72+
let err = try
73+
ambig_with_bounds(1, 2, 3)
74+
catch _e_
75+
_e_
76+
end
77+
io = IOBuffer()
78+
Base.showerror(io, err)
79+
lines = split(String(take!(io)), '\n')
80+
@test lines[end] == " ambig_with_bounds(::$Int, ::$Int, ::T) where T<:Integer"
81+
end
82+
7083
## Other ways of accessing functions
7184
# Test that non-ambiguous cases work
7285
let io = IOBuffer()

0 commit comments

Comments
 (0)