Help with structures using `Val`


#1

Hi guys,

Can anyone explain me why this code is not working:

struct Design_Variable{T<:Union{Type{Val{:MGEO_Canonical}},
                                Type{Val{:MGEO_Var}}}}
    bits::Int64
    min::Float64
    max::Float64
    full_scale::Int64
    index::Int64
    name::AbstractString
end
julia> Design_Variable{Val{:MGEO_Canonical}}(10,10.,10.,10,10,"Var")
ERROR: TypeError: in Design_Variable, in T, expected T<:Union{Type{Val{:MGEO_Canonical}}, Type{Val{:MGEO_Var}}}, got Type{DataType}

#2

This works

struct Design_Variable{T<:Union{Val{:MGEO_Canonical},
                                       Val{:MGEO_Var}}}
           bits::Int64
           min::Float64
           max::Float64
           full_scale::Int64
           index::Int64
           name::AbstractString
end

since Val is already a type. The Type{..} is only necessary in annotations and not as a type parameter.