Skip to content

Commit

Permalink
Merge pull request JuliaLang#7497 from Aerlinger/better_error_message…
Browse files Browse the repository at this point in the history
…_for_no_method

Better error message for no method
  • Loading branch information
ivarne committed Jul 4, 2014
2 parents a6b6104 + f78f6a7 commit 0047370
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions base/replutil.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ end

writemime(io::IO, ::MIME"text/plain", t::Associative) =
showdict(io, t, limit=true)
writemime(io::IO, ::MIME"text/plain", t::Union(KeyIterator,ValueIterator)) =
writemime(io::IO, ::MIME"text/plain", t::Union(KeyIterator, ValueIterator)) =
showkv(io, t, limit=true)


Expand All @@ -52,15 +52,15 @@ function showerror(io::IO, e::TypeError)
print(io, "type: non-boolean ($(typeof(e.got))) ",
"used in boolean context")
else
if isa(e.got,Type)
if isa(e.got, Type)
tstr = "Type{$(e.got)}"
else
tstr = string(typeof(e.got))
end
print(io, "type: $(e.func): ",
"$(ctx)expected $(e.expected), ",
"got $tstr")
if e.func === :apply && e.expected <: Function && isa(e.got,AbstractArray)
if e.func === :apply && e.expected <: Function && isa(e.got, AbstractArray)
println(io)
print(io, "Use square brackets [] for indexing.")
end
Expand All @@ -84,7 +84,7 @@ end
function showerror(io::IO, e::DomainError, bt)
print(io, "DomainError")
for b in bt
code = ccall(:jl_lookup_code_address, Any, (Ptr{Void},Cint), b, true)
code = ccall(:jl_lookup_code_address, Any, (Ptr{Void}, Cint), b, true)
if length(code) == 4
if code[1] in (:log, :log2, :log10, :sqrt) # TODO add :besselj, :besseli, :bessely, :besselk
print(io, "\n", code[1],
Expand All @@ -110,22 +110,22 @@ showerror(io::IO, e::InterruptException) = print(io, "interrupt")
function showerror(io::IO, e::MethodError)
name = isgeneric(e.f) ? e.f.env.name : :anonymous
if isa(e.f, DataType)
print(io, "no method $(e.f)(")
print(io, "constructor `$(e.f)` has no method matching signature $(e.f)(")
else
print(io, "no method $(name)(")
print(io, "function `$(name)` has no method matching signature $(name)(")
end
for (i, arg) in enumerate(e.args)
if isa(arg,Type) && arg != typeof(arg)
if isa(arg, Type) && arg != typeof(arg)
print(io, "Type{$(arg)}")
else
print(io, typeof(arg))
print(io, "::$(typeof(arg))")
end
i == length(e.args) || print(io,", ")
i == length(e.args) || print(io, ", ")
end
print(io, ")")
if isdefined(Base,name)
f = eval(Base,name)
if f !== e.f && isgeneric(f) && applicable(f,e.args...)
if isdefined(Base, name)
f = eval(Base, name)
if f !== e.f && isgeneric(f) && applicable(f, e.args...)
println(io)
print(io, "you may have intended to import Base.$(name)")
end
Expand Down Expand Up @@ -165,7 +165,7 @@ function show_backtrace(io::IO, top_function::Symbol, t, set)
local fname, file, line
count = 0
for i = 1:length(t)
lkup = ccall(:jl_lookup_code_address, Any, (Ptr{Void},Cint), t[i], true)
lkup = ccall(:jl_lookup_code_address, Any, (Ptr{Void}, Cint), t[i], true)
if lkup === ()
continue
end
Expand Down

0 comments on commit 0047370

Please sign in to comment.