Skip to content

Fix @static_unpack type parameters and add JET tests#324

Closed
ChrisRackauckas-Claude wants to merge 1 commit into
SciML:mainfrom
ChrisRackauckas-Claude:static-improvements-20260107-142231
Closed

Fix @static_unpack type parameters and add JET tests#324
ChrisRackauckas-Claude wants to merge 1 commit into
SciML:mainfrom
ChrisRackauckas-Claude:static-improvements-20260107-142231

Conversation

@ChrisRackauckas-Claude
Copy link
Copy Markdown
Contributor

Summary

  • Fix _maybe_SArray functions in static_arrays.jl: The original code was trying to construct SVector{N}(x) and SArray{Tuple{Sz...}}(x) without element type parameters and without converting to Tuple, which caused MethodErrors. Now properly constructs SVector{N, T}(Tuple(x)) and SArray{Tuple{Sz...}, T, N, prod(Sz)}(Tuple(x)).
  • Add JET.jl tests: Added JET.jl as a test dependency and created test/jet_tests.jl to test type stability of core ComponentArray operations (getdata, getaxes, getindex).

Background

Ran JET.jl analysis on the package which identified several issues. The most actionable one was the _maybe_SArray functions used by @static_unpack which had incorrect type signatures for constructing SVector and SArray types. The macro now correctly returns SVector and SMatrix types.

Before fix:

julia> @static_unpack a, b = ComponentArray(a = 5.0, b = [1.0, 2.0])
ERROR: MethodError: no method matching (SArray{Tuple{2}})(::SubArray{Float64, 1, Vector{Float64}, Tuple{UnitRange{Int64}}, true})

After fix:

julia> @static_unpack a, b = ComponentArray(a = 5.0, b = [1.0, 2.0])
julia> typeof(b)
SVector{2, Float64}

Test plan

  • All existing tests pass (Pkg.test())
  • New JET tests pass
  • Manually tested @static_unpack with vectors and matrices

cc @ChrisRackauckas

🤖 Generated with Claude Code

- Fix _maybe_SArray functions in static_arrays.jl to properly construct SVector
  and SArray types by including element type parameter and using Tuple(x)
  conversion for type stability
- Add JET.jl as test dependency
- Add JET type stability tests for core ComponentArray operations
- The @static_unpack macro now correctly returns SVector and SMatrix types

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@ChrisRackauckas-Claude ChrisRackauckas-Claude force-pushed the static-improvements-20260107-142231 branch from a588abe to a88fc9a Compare January 9, 2026 12:51
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

Successfully merging this pull request may close these issues.

3 participants