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

Constructor doesn't fall back to convert? #15611

Closed
colinfang opened this issue Mar 24, 2016 · 2 comments
Closed

Constructor doesn't fall back to convert? #15611

colinfang opened this issue Mar 24, 2016 · 2 comments

Comments

@colinfang
Copy link
Contributor

immutable AAA
    x::Int
end
Base.convert(::Type{AAA}, x::Float64) = AAA(1)
AAA(1.1)
# Inexact error

Seems there is another rule taking priority over the fallback.

Is this the desired behaviour? Do I have to manually build a constructor A(x::Float64) in this case?

@tomaklutfu
Copy link
Contributor

I think this was covered as document issue a while ago. There is always one argument default constructor from Base definitions. So, you need A(x::Float64).

@yuyichao
Copy link
Contributor

Dup of #15120

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants