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 returns nothing #2161

Closed
adambrewster opened this issue Jan 30, 2013 · 1 comment
Closed

Constructor returns nothing #2161

adambrewster opened this issue Jan 30, 2013 · 1 comment
Assignees
Milestone

Comments

@adambrewster
Copy link

The following test fails on the second to last line. Maybe I'm an idiot, but this behavior seems really weird if it's not a bug. Running bda9432 on a 32-bit machine in case that matters. The commented out version of the constructor ABCD seems to make things work.

type AB{T<:Real}
    a::T
    b::T
end
AB{T<:Real}(a::T, b::T) = AB{T}(a, b)
AB(a::Real, b::Real) = AB(promote(a, b)...)
@test typeof(AB(0.0, 0)) != Nothing
@test typeof(AB(0, 0.0)) != Nothing

type ABC{T<:Real}
    a::T
    b::T
    c::T
end
ABC{T<:Real}(a::T, b::T, c::T) = ABC{T}(a, b, c)
ABC(a::Real, b::Real, c::Real) = ABC(promote(a, b, c)...)
@test typeof(ABC(0.0, 0, 0)) != Nothing
@test typeof(ABC(0, 0.0, 0)) != Nothing
@test typeof(ABC(0, 0, 0.0)) != Nothing

type ABCD{T<:Real}
    a::T
    b::T
    c::T
    d::T
end
ABCD{T<:Real}(a::T, b::T, c::T, d::T) = ABCD{T}(a, b, c, d)
ABCD(a::Real, b::Real, c::Real, d::Real) = ABCD(promote(a, b, c, d)...)
#ABCD(a::Real, b::Real, c::Real, d::Real) = ABCD(promote(a, promote(b, promote(c, d)...)...)...)

@test typeof(ABCD(0.0, 0, 0, 0)) != Nothing
@test typeof(ABCD(0, 0.0, 0, 0)) != Nothing
@test typeof(ABCD(0, 0, 0.0, 0)) != Nothing # fails here
@test typeof(ABCD(0, 0, 0, 0.0)) != Nothing

[pao: formatting, note that @test (or any Julia macro call) outside a quote block in an issue will ping that user on GitHub, who must be very cross with us by now]

@Keno
Copy link
Member

Keno commented Jan 31, 2013

Seems like a bug to me as well.

/cc @JeffBezanson

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