I have the following struct and I’m a little confused why using @code_warntype on it’s construct says there’s unstable types. The output from that command is a little verbose but I’ll copy one of the red parts in case that is useful. Any help would be appreciated, thanks!
mutable struct System{T, M, MS, N, L, K}
coords::Matrix{T}
coords_initial::Matrix{T}
coords_unwrapped::Matrix{T}
masses::SVector{N,M}
masses_sqrt::SVector{N,MS}
box_size::L
n_particles::Integer
kB::K
end
function System(r0, masses, box_size, N_atoms, kB)
masses_sqrt = sqrt.(masses)
return System{eltype(r0), eltype(masses), eltype(masses_sqrt), N_atoms, typeof(box_size), typeof(kB)}(
deepcopy(r0), deepcopy(r0), deepcopy(r0), masses, masses_sqrt, box_size, N_atoms, kB)
end
│ %22 = Core.apply_type(Main.System, %17, %18, %19, N_atoms, %20, %21)::Type{System{Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothi
ng}}, Quantity{Float64, 𝐌 𝐍^-1, Unitful.FreeU
nits{(g, mol^-1), 𝐌 𝐍^-1, nothing}}, Quantity
{Float64, 𝐌^1/2 𝐍^-1/2, Unitful.FreeUnits{(g^
1/2, mol^-1/2), 𝐌^1/2 𝐍^-1/2, nothing}}, _A,
Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), �
, nothing}}, Quantity{Float64, 𝐋^2 𝐌 𝐍^-1 �
^^-1 𝐓^-2, Unitful.FreeUnits{(kcal, K^-1, mol^
-1), 𝐋^2 𝐌 𝐍^-1 𝚯^-1 𝐓^-2, nothing}}}} whe
re _A