Skip to content

Commit

Permalink
fix bug in HTML showing of method table of function with parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Jun 28, 2017
1 parent f31e163 commit 2f1d30d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
14 changes: 8 additions & 6 deletions base/methodshow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,16 @@ end
function show(io::IO, m::Method; kwtype::Nullable{DataType}=Nullable{DataType}())
tv, decls, file, line = arg_decl_parts(m)
sig = unwrap_unionall(m.sig)
ft = unwrap_unionall(sig.parameters[1])
ft0 = sig.parameters[1]
ft = unwrap_unionall(ft0)
d1 = decls[1]
if sig === Tuple
print(io, m.name)
decls = Any[(), ("...", "")]
elseif ft <: Function &&
elseif ft <: Function && isa(ft, DataType) &&
isdefined(ft.name.module, ft.name.mt.name) &&
# TODO: more accurate test? (tn.name === "#" name)
ft == typeof(getfield(ft.name.module, ft.name.mt.name))
ft0 === typeof(getfield(ft.name.module, ft.name.mt.name))
print(io, ft.name.mt.name)
elseif isa(ft, DataType) && ft.name === Type.body.name && isleaftype(ft)
f = ft.parameters[1]
Expand Down Expand Up @@ -226,11 +227,12 @@ end
function show(io::IO, ::MIME"text/html", m::Method; kwtype::Nullable{DataType}=Nullable{DataType}())
tv, decls, file, line = arg_decl_parts(m)
sig = unwrap_unionall(m.sig)
ft = sig.parameters[1]
ft0 = sig.parameters[1]
ft = unwrap_unionall(ft0)
d1 = decls[1]
if ft <: Function &&
if ft <: Function && isa(ft, DataType) &&
isdefined(ft.name.module, ft.name.mt.name) &&
ft == typeof(getfield(ft.name.module, ft.name.mt.name))
ft0 === typeof(getfield(ft.name.module, ft.name.mt.name))
print(io, ft.name.mt.name)
elseif isa(ft, DataType) && ft.name === Type.body.name && isleaftype(ft)
f = ft.parameters[1]
Expand Down
12 changes: 11 additions & 1 deletion test/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -778,4 +778,14 @@ let fname = tempname()
finally
rm(fname, force=true)
end
end
end

struct f_with_params{t} <: Function
end

(::f_with_params)(x) = 2x

let io = IOBuffer()
show(io, MIME"text/html"(), f_with_params.body.name.mt)
@test contains(String(take!(io)), "f_with_params")
end

0 comments on commit 2f1d30d

Please sign in to comment.