Error when a sumtype has variants with the same names with abstract parameters and concrete parameters at the same time
The problematic cases are e.g.:
julia> using DynamicSumTypes
julia> struct B{T}
x::T
end
julia> @sumtype A{T}(B{T}, B{Int})
A
julia> @sumtype A2(B{T} where T, B{Int})
A2
they are not good because one variant is not reacheable because of the presence of the more general one. Actually this would be fine:
julia> @sumtype A{T}(B{Int}, B{T})
because here B{Int} will be searched first. So, maybe allow something like this and error only in the other case?
EDIT: Looks like you have added parameters in the meantime. I'll check it out.
This gives me an invalid syntax error.
@sumtype A{T}(B{T}, B{Int})
And it's clear your code does not support parameterized sumtypes. I commented on the discourse post about this. Do you have another branch that supports this? If not, it shouldn't be hard to add it.
It would be good to detect the possible collision when T == Int and insert a check in the constructor.
Unfortunatley, all of this starts to add lines to your slim 150 line code.
yes, I added the support for parametrized types. Actually I think that
@sumtype` A{T}(B{T}, B{Int})
could be supported but we need to reorder internally the types so that concrete version precedes the abstract one. But actually there are other cases that I think we should anyway handle by throwing some errors