Fails on UnionAlls
Closed this issue · 6 comments
julia> about(Vector)
UnionAllERROR: type UnionAll has no field name
Stacktrace:
[1] getproperty
@ ./Base.jl:43 [inlined]
[2] about(io::Base.TTY, type::Type)
@ About ~/.julia/packages/About/XPN7V/src/types.jl:48
[3] about(x::Type)
@ About ~/.julia/packages/About/XPN7V/src/About.jl:24
[4] top-level scope
@ REPL[12]:1
I had been hoping it would tell me what type parameters it had and what restrictions are on them.
We have code that does something like that in
https://github.com/invenia/ExprTools.jl/blob/bcc7765a177f39363dfcc9d9310c97ca26530a78/src/method.jl#L163-L174
Thanks for this issue! I think it would be neat to incorporate functionality like that.
Would it take much effort for you to provide a sample "this is what I liked to see" output I can look at to complement the code you linked? I'm thinking the two together should help me give this a shot.
Consider a struct:
struct Foo{X<:Integer, Y}
x::X
y::Y
z::Int64
end
I would like to see
UnionAll defined in Main,
Foo{X<:Integer, Y} <: Any
Struct with 3 fields:
• x X
• y Y
• z Int64
Recent changes seem to have this working, but perhaps with some room for improvement
julia> about(Vector)
UnionAll defined in Core,
Vector <: DenseVector <: AbstractVector <: Any
Struct with 2 fields:
• ref::MemoryRef
• size::Tuple{Int64}
julia> about(Foo)
UnionAll defined in Main,
Foo <: Any
Struct with 3 fields:
• x::Integer
• y::Any
• z::Int64
Here we go, how about this?
julia> about(Vector)
UnionAll defined in Core,
Array{T, 1} <: DenseArray{T, 1} <: AbstractArray{T, 1} <: Any
Struct with 2 fields:
• ref::MemoryRef
• size::Tuple{Int64}
julia> about(Foo)
UnionAll defined in Main,
Foo{X<:Integer, Y} <: Any
Struct with 3 fields:
• x::Integer
• y::Any
• z::Int64
It is reasonable.
Its a little loss of information if the type-var is used in multiple places
but that may be acceptable
Well, I've just pushed that. Do let me know if you have any ideas for further improvement 🙂 For now, onto Memory
and String
s...