Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SVector{N,T} only accept Int64 but not Int32 #1233

Open
Blumenkranz opened this issue Jan 15, 2024 · 5 comments
Open

SVector{N,T} only accept Int64 but not Int32 #1233

Blumenkranz opened this issue Jan 15, 2024 · 5 comments

Comments

@Blumenkranz
Copy link

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.

@mattsignorelli
Copy link

mattsignorelli commented Jan 28, 2025

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

@nsajko
Copy link
Contributor

nsajko commented Jan 28, 2025

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 Int must be specifically used.

That's the current error message IMO. Do you have a specific idea on how to improve it?

@nsajko
Copy link
Contributor

nsajko commented Jan 28, 2025

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?

@nsajko
Copy link
Contributor

nsajko commented Jan 28, 2025

Opened an upstream issue: JuliaLang/julia#57189

@nsajko
Copy link
Contributor

nsajko commented Feb 1, 2025

duplicate of #798

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants