Skip to content

Commit

Permalink
don't print Type{Vararg} in type errors, since that expr is invalid (
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson authored Nov 29, 2018
1 parent 2ec5560 commit 89a2c08
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion base/errorshow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ function showerror(io::IO, ex::TypeError)
if ex.expected === Bool
print(io, "non-boolean (", typeof(ex.got), ") used in boolean context")
else
if isa(ex.got, Type)
if isvarargtype(ex.got)
targs = (ex.got,)
elseif isa(ex.got, Type)
targs = ("Type{", ex.got, "}")
else
targs = (typeof(ex.got),)
Expand Down
2 changes: 2 additions & 0 deletions test/errorshow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ let undefvar
@test err_str == "TypeError: in Type, in parameter, expected Type, got String"
err_str = @except_str TypeWithIntParam{Any} TypeError
@test err_str == "TypeError: in TypeWithIntParam, in T, expected T<:Integer, got Type{Any}"
err_str = @except_str Type{Vararg} TypeError
@test err_str == "TypeError: in Type, in parameter, expected Type, got Vararg"

err_str = @except_str mod(1,0) DivideError
@test err_str == "DivideError: integer division error"
Expand Down

0 comments on commit 89a2c08

Please sign in to comment.