SVector{N,T} only accept Int64 but not Int32
Maybe Tuple{Vararg{Union{StaticArraysCore.Dynamic, Int64}}} can be changed to Tuple{Vararg{Union{StaticArraysCore.Dynamic, Integer}}}? When I use C API, all integers are Cint, i.e. Int32, which requires extra type conversion.
I also ran into this problem, unfortunately wasting two hours of my work to find this was the cause.
All throughout the StaticArrays package, ::Int is used where ::Integer should be allowed, just like all AbstractArrays in Julia. Or at the least, a descriptive error should be printed stating Int must be specifically used.
julia> length(MVector{6})
6
julia> length(MVector{Cint(6)})
ERROR: TypeError: in typeassert, expected Tuple{Vararg{Union{StaticArraysCore.Dynamic, Int64}}}, got a value of type Tuple{Int32}
Stacktrace:
[1] Size{(6,)}()
@ StaticArraysCore ~/.julia/packages/StaticArraysCore/7xxEJ/src/StaticArraysCore.jl:488
[2] Size(::Type{Tuple{6}})
@ StaticArraysCore ~/.julia/packages/StaticArraysCore/7xxEJ/src/StaticArraysCore.jl:495
[3] Size(::Type{MVector{6}})
@ StaticArraysCore ~/.julia/packages/StaticArraysCore/7xxEJ/src/StaticArraysCore.jl:517
[4] length(a::Type{MVector{6}})
@ StaticArrays ~/.julia/packages/StaticArrays/xEhFV/src/abstractarray.jl:2
[5] top-level scope
@ REPL[9]:1
Relaxing Int to Integer is not really an option. Consider this:
julia> Val{Int32(7)} == Val{Int64(7)}
false
Or at the least, a descriptive error should be printed stating
Intmust be specifically used.
That's the current error message IMO. Do you have a specific idea on how to improve it?
When I use C API, all integers are Cint, i.e. Int32, which requires extra type conversion.
In what way is that an issue? Does the conversion not constant fold?
Opened an upstream issue: https://github.com/JuliaLang/julia/issues/57189
duplicate of #798
Encountered this issue as well, and the error message in no way hinted that the problem was in the Int32 type...
LoadError: ArgumentError: cannot reinterpret `Float32` as `StaticArraysCore.SVector{4, Float32}`,
type `StaticArraysCore.SVector{4, Float32}` is not a bits type
Where 4 is a Int32 and not Int64. But that is not explicitly shown due to https://github.com/JuliaLang/julia/issues/57189
unfortunately wasting two hours of my work to find this was the cause.
+ another two hours wasted here 🙄
To reproduce;
using StaticArrays
x = ones(8)
sv = SVector{4, Float64}
reinterpret(sv, x) # runs fine
sv = SVector{Int32(4), Float64} # no error here
reinterpret(sv, x) # "not a bits type" error