-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Confusing MethodError when display
fails due to an ambiguous method call to show
#18221
Comments
the confusing part is probably that the MethodError was manually thrown: 153 function display(x)
154 for i = length(displays):-1:1
155 xdisplayable(displays[i], x) &&
156 @try_display return display(displays[i], x)
157 end
158 throw(MethodError(display, (x,)))
159 end this hides the actual error: julia> show(A())
ERROR: MethodError: show(::Base.TTY, ::A) is ambiguous. Candidates:
show(io, ::A) at REPL[2]:1
show(io::IO, x::ANY<:Any) at show.jl:116
in show(::A) at coreio.jl:3
in eval(::Module, ::Any) at ./boot.jl:234
in eval(::Module, ::Any) at /Users/jameson/julia/usr/lib/julia/sys-debug.dylib:?
in eval_user_input(::Any, ::Base.REPL.REPLBackend) at REPL.jl:66
in macro expansion; at REPL.jl:97 [inlined]
in (::Base.REPL.##3#4{Base.REPL.REPLBackend})() at event.jl:68 |
display
fails due to an ambiguous method call to show
x-ref #18018 |
I've hit this issue. I was trying to create a dispatch for showing JavaScript values within HypertextLiteral.
I would expect the latter error. The former error is not easily discoverable. I believe there is a failed attempt to "look before you leap".
I think I see two issues. First, This isn't high priority for me. I can use a generated function to work around the problem.
This essentially bypasses the catch of |
This is still quite terrible actually |
I understand that in order to extend
Base.show
one needs to qualify the type ofio
in the argument signature (I encountered the following behavior while trying without the qualification...), so this shouldn't work... But the backtrace is really quite confusing, since it seems impossible that there should be aMethodError
for a particular argument signature fordisplay
and yet (i)display
has a methoddisplay(x)
and (ii) the error occurs inside a call todisplay
with precisely the same signature as is being complained about.The text was updated successfully, but these errors were encountered: