This is proving impossible to work around.

Firstly, I can't seem to produce a minimal example of the behaviour I just 
mentioned. If the promote_rule_exists function is placed in the Nemo module 
itself it returns a different value to if I define the function at the 
REPL. But if I place it in a module created in the REPL, it behaves as 
expected.

So instead I tried the following:

julia> using Nemo

julia> promote_type(Nemo.Poly{Nemo.Residue{Nemo.fmpq_poly}}, Nemo.fmpq_poly)
Nemo.PolyElem{T}

julia> @which promote_type(Nemo.Poly{Nemo.Residue{Nemo.fmpq_poly}}, 
Nemo.fmpq_poly)
promote_type{T,S}(::Type{T}, ::Type{S}) at promotion.jl:121

Why is Julia defining a completely generic promote_rule for types it knows 
nothing about, and giving a completely invalid type as the result?

I thought of just defining:

function promote_rule_exists{T1, T2}(::Type{T1}, ::Type{T2})
   return promote_type(T1, T2) == T1
end

Since all the promote_rules we create are of this form. But then it returns 
true for cases where promote_type(T1, T2) is not T1!! This seems to happen 
in cases where promote_type returns a parameterised type rather than a 
concrete type (and thus presumably is coming from a promote_rule defined by 
Julia.

But it doesn't consistently return true in such a case, making it 
impossible to work around the problem.

Basically it looks to me like there is a large amount of breakage in 
current master. Either that or promote_type, promote_rule, == and "in" are 
now all so counterintuitive that I don't understand how they work. Or I 
suppose I could just be being very stupid about something.

Bill.







Reply via email to