I have the following:
const ScalarVariateVal = Real
const ArrayVariateVal{N,VT<: ScalarVariateVal} = DenseArray{VT, N}
const DictVariateVal{K,VT<: ScalarVariateVal} = Associative{K, VT}
const AbstractVariateVal{V<:ScalarVariateVal} = Union{V, (ArrayVariateVal{XX,V} where XX), (DictVariateVal{XX,V} where XX)}
And then, in another file:
valtype{VT}(x::AbstractVariateVal{VT}) = VT
The problem is that the V<:ScalarVariateVal
in the definition of AbstractVariateVal seems to be getting lost somehow. That is, the above method for valtype is getting called with VT==DataType… but then, since DataType is its own type, that leads to infinite recursion.
I tried to add “where V<:ScalarVariateVal” to each instance of V in the RHS definition of AbstractVariateVal, but that gives another error I don’t understand: “expected UnionAll, got Type{Union{Associative{XX,V} where XX where V<:Real, DenseArray{V,XX} where XX where V<:Real, Real}}”. Isn’t UnionAll the type for anything that starts “Type{Union{…”?
I can certainly find workarounds for these issues, but should I report them? Are they bugs in Julia, or just failures of my own understanding?