Julia: Printing for MethodError of partially applied type

Created on 1 Jul 2017  Â·  2Comments  Â·  Source: JuliaLang/julia

I don't like the printing of this:

julia> struct foo{S,T}; end

julia> foo{Int64}()
ERROR: MethodError: no method matching foo{Int64,T} where T()

Some options that I think would be better:

ERROR: MethodError: no method matching foo{Int64,T}()
ERROR: MethodError: no method matching (foo{Int64,T} where T)()

Don't want to prescribe what it should look like, but something along those lines seems better.

display and printing help wanted

Most helpful comment

or foo{Int64, <:Any}() ?

All 2 comments

or foo{Int64, <:Any}() ?

julia> struct Bar{S,T<:Number,U<:T} end

julia> Bar{String,Integer,Int}
Bar{String,Integer,Int64}

julia> Bar{String}
Bar{String,T,U} where U<:T where T<:Number

Because there could be restrictions on T, it seems that the error would be less clear if the where statement was omitted entirely.

Using only <:SomeType could be unclear, as well. In this case, by replacing the second parameter by <:Number, the third parameter should logically become <:T. However, T is not referenced anywhere else in the error message.

As far as I can tell, the clearest formats would be as follows, with the second providing the benefit of being a bit more concise.

ERROR: MethodError: no method matching (Bar{String,T,U} where U<:T where T<:Number)()
ERROR: MethodError: no method matching Bar{String,T<:Number,U<:T}()
Was this page helpful?
0 / 5 - 0 ratings