[julia-users] Type promotion bug?

2015-08-25 Thread Sisyphuss
abstract B type A<:B end type C<:B end promote_rule(::Type{A},::Type{C}) = C @assert promote_type(A,C) == B Whether I define the promotion_rule or not, the promote_type is always B.

Re: [julia-users] Type promotion bug?

2015-08-25 Thread Tim Holy
Add `Base.` in front of `promote_rule`. --Tim On Tuesday, August 25, 2015 08:23:40 PM Sisyphuss wrote: > abstract B > > type A<:B > end > > type C<:B > end > > promote_rule(::Type{A},::Type{C}) = C > > @assert promote_type(A,C) == B > > Whether I define the promotion_rule or not, the promote

Re: [julia-users] Type promotion bug?

2015-08-25 Thread Sisyphuss
This modification works, but it fails sometimes: abstract B{T} type A{T}<:B{T} end type C{T}<:B{T} end promote_rule() = 1 promote_rule() @assert promote_type(A{Real},C{Real}) == B{Real} Base.promote_rule{T}(::Type{A{T}},::Type{C{T}}) = C{T} @assert promote_type(A{Real},C{Real}) == B{Real} @ass

Re: [julia-users] Type promotion bug?

2015-08-25 Thread Stefan Karpinski
Don't do the first non-base definition. On Wed, Aug 26, 2015 at 12:27 AM, Sisyphuss wrote: > This modification works, but it fails sometimes: > > abstract B{T} > > type A{T}<:B{T} > end > > type C{T}<:B{T} > end > > promote_rule() = 1 > promote_rule() > @assert promote_type(A{Real},C{Real}) == B

Re: [julia-users] Type promotion bug?

2015-08-26 Thread Sisyphuss
In other words, it "won't fix"? On Wednesday, August 26, 2015 at 6:41:36 AM UTC+2, Stefan Karpinski wrote: > > Don't do the first non-base definition. > > On Wed, Aug 26, 2015 at 12:27 AM, Sisyphuss > wrote: > >> This modification works, but it fails sometimes: >> >> abstract B{T} >> >> type A{T}

Re: [julia-users] Type promotion bug?

2015-08-26 Thread Luthaf
By doing promote_rule() = 1 And then Base.promote_rule{T}(::Type{A{T}},::Type{C{T}}) = C{T} You are defining two different functions. Only the second one is used by the promotion system. The valid code is abstract B type A<:B end type C<:B end Base.promote

Re: [julia-users] Type promotion bug?

2015-08-26 Thread Sisyphuss
Of course, I know how to write the valid code. But in the interactive environment, if someone accidentally defines the promote_rule in the non-base way, he will find himself in an incomprehensible situation. On Wednesday, August 26, 2015 at 4:15:59 PM UTC+2, Luthaf wrote: > > By doing > >

Re: [julia-users] Type promotion bug?

2015-08-26 Thread Yichao Yu
On Wed, Aug 26, 2015 at 12:44 PM, Sisyphuss wrote: > Of course, I know how to write the valid code. > > But in the interactive environment, if someone accidentally defines the > promote_rule in the non-base way, he will find himself in an > incomprehensible situation. There's too many things you

Re: [julia-users] Type promotion bug?

2015-08-26 Thread Joshua Ballanco
On August 26, 2015 at 21:30:47, Yichao Yu (yyc1...@gmail.com(mailto:yyc1...@gmail.com)) wrote: > On Wed, Aug 26, 2015 at 12:44 PM, Sisyphuss wrote: > > Of course, I know how to write the valid code. > > > > But in the interactive environment, if someone accidentally defines the > > promote_rul

Re: [julia-users] Type promotion bug?

2015-08-27 Thread Sisyphuss
I tried your example. Really, you can break Julia in this way. Luckily, it's a syntax error. However, mine is a semantic error, and harder to detect. On Wednesday, August 26, 2015 at 8:30:47 PM UTC+2, Yichao Yu wrote: > > On Wed, Aug 26, 2015 at 12:44 PM, Sisyphuss > wrote: > > Of course, I k

Re: [julia-users] Type promotion bug?

2015-08-27 Thread Milan Bouchet-Valat
Le jeudi 27 août 2015 à 09:13 +0300, Joshua Ballanco a écrit : > On August 26, 2015 at 21:30:47, Yichao Yu (yyc1...@gmail.com(mailto: > yyc1...@gmail.com)) wrote: > > On Wed, Aug 26, 2015 at 12:44 PM, Sisyphuss wrote: > > > Of course, I know how to write the valid code. > > > > > > But in the in