Hi, I was trying to define an abstract type which I would like to be subtype of FieldVector{N,T}, from the package StaticArrays, where N must be Unsigned. If it were simply a case like the following
abstract type MyType{N, T} <: FieldVector{N, T} end
everything is ok, it precompiles an executes beautifully. The problem arises when I do want to manipulate N before passing it to FieldVector. For example if I were to try and write
abstract type MyType{N, T} <: FieldVector{2N, T} end
the resulting error would state
ERROR: MethodError: no method matching *(::Int64, ::TypeVar)
Closest candidates are:
*(::Any, ::Any, ::Any, ::Any...) at operators.jl:560
*(::T, ::T) where T<:Union{Int128, Int16, Int32, Int64, Int8, UInt128, UInt16, UInt32, UInt64, UInt8} at int.jl:88
*(::Union{Int16, Int32, Int64, Int8}, ::BigInt) at gmp.jl:541
...
Stacktrace:
[1] top-level scope
@ REPL[4]:1
which clearly indicates that, by default, any type parameter is interpretered as a TypeVar instance which, obviously, has no multiplication operation defined. So I try and specify to the compiler that N is of type Unsigned using the same syntax I use for the functions
abstract type MyType{N::Unsigned, T} <: FieldVector{2N, T} end
but this raises the cryptic error
ERROR: syntax: invalid variable expression in "where" around REPL[5]:1
Stacktrace:
[1] top-level scope
@ REPL[5]:1
So my question is: how do I tell the compiler that N is a non-type type parameter?
I tried to look for examples of this behavior online and in the source code of some libraries but I found no solution in my search.