Skip to content
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

Regression in empty constructor falling back to defined convert method #16887

Closed
jakebolewski opened this issue Jun 12, 2016 · 4 comments
Closed
Labels
types and dispatch Types, subtyping and method dispatch

Comments

@jakebolewski
Copy link
Member

The following fails on 0.5-dev but works on 0.4

julia/julia-dev [master] » julia-dev
               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.5.0-dev+4646 (2016-06-10 11:00 UTC)
 _/ |\__'_|_|_|\__'_|  |  Commit 56d7d66* (1 day old master)
|__/                   |  x86_64-apple-darwin15.5.0

julia> bitstype 8 ThreeWay

julia> Base.convert(::Type{ThreeWay}, x::Bool) = reinterpret(ThreeWay, x)

julia> Base.convert(::Type{ThreeWay}) = reinterpret(ThreeWay, 0xff)

julia> ThreeWay()
ERROR: MethodError: no method matching ThreeWay()
 in eval(::Module, ::Any) at ./boot.jl:225
 in macro expansion at ./REPL.jl:92 [inlined]
 in (::Base.REPL.##1#2{Base.REPL.REPLBackend})() at ./event.jl:46
Julia/julia-dev [master] » julia
               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.4.5 (2016-03-18 00:58 UTC)
 _/ |\__'_|_|_|\__'_|  |
|__/                   |  x86_64-apple-darwin15.4.0

LoadError("/Users/jacobbolewski/.julia/v0.4/TerminalExtensions/src/TerminalExtensions.jl",237,InitError(:TerminalExtensions,ErrorException("Timed out!")))
julia> bitstype 8 ThreeWay

julia> Base.convert(::Type{ThreeWay}, x::Bool) = reinterpret(ThreeWay, x)
convert (generic function with 535 methods)

julia> Base.convert(::Type{ThreeWay}) = reinterpret(ThreeWay, 0xff)
convert (generic function with 536 methods)

julia> ThreeWay()
ThreeWay(0xff)
@JeffBezanson
Copy link
Sponsor Member

I think the fallback definition used to use args..., and we switched it to take a single argument, since it seemed to make the most sense to convert a single value.

@jakebolewski
Copy link
Member Author

That makes sense, maybe there are bits of documentation that need updating? Otherwise feel free to close.

@jakebolewski
Copy link
Member Author

I think that if you are limiting yourself to one argument convert method fallbacks, the error message could be updated to ...fall back to convert(::Type{AType}, x) methods

@kshyatt kshyatt added the types and dispatch Types, subtyping and method dispatch label Jan 26, 2017
@JeffBezanson
Copy link
Sponsor Member

This fallback has been removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
types and dispatch Types, subtyping and method dispatch
Projects
None yet
Development

No branches or pull requests

3 participants