# OrdinaryDiffEq solve: "TypeError in setfield!" when using MVector

**URL:** https://discourse.julialang.org/t/ordinarydiffeq-solve-typeerror-in-setfield-when-using-mvector/105960
**Category:** Numerics
**Tags:** staticarrays, ordinarydiffeq
**Created:** [November 8, 2023, 4:20pm UTC](https://discourse.julialang.org/t/ordinarydiffeq-solve-typeerror-in-setfield-when-using-mvector/105960 "2023-11-08T16:20:53Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![laikq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/laikq/32/51949_2.png) [@laikq](https://discourse.julialang.org/u/laikq)
#### Post date: [November 8, 2023, 4:20pm UTC](https://discourse.julialang.org/t/ordinarydiffeq-solve-typeerror-in-setfield-when-using-mvector/105960/1 "2023-11-08T16:20:53Z")

</div>

I get an error

> TypeError: in setfield!, expected `Tuple{LinearAlgebra.LU{Float64, Matrix{Float64}, Vector{Int64}}, Base.RefValue{Int64}}`, got a value of type `Tuple{LinearAlgebra.LU{Float64, StaticArraysCore.MMatrix{4, 4, Float64, 16}, Vector{Int64}}, Base.RefValue{Int64}}`  
> _(difference is Matrix vs MMatrix)_

while calling OrdinaryDiffEq’s `solve` with algorithm `AutoTsit5(Rodas4P())` or `Rodas4P(autodiff=false)`. Minimal (non-)working example:

```julia
using OrdinaryDiffEq, StaticArrays

function mwe_rule!(out, u, p, t)
	out .= -u
	nothing
end

# ↓ this will work
u0 = zeros(4)
# ↓ this will throw the error
#u0 = @MVector(zeros(4))
p = ODEProblem(mwe_rule!, u0, (0., 12.))
sol = solve(p, Rodas4P(autodiff=false))

```

This was weird to find, because in my case I am working with disturbed systems and the error only occurs with very small disturbance strengths. Happens on OrdinaryDiffEq v6.58.0

_Edit:_ Seems this is fixed by an upgrade to OrdinaryDiffEq v6.59.0, possibly related to [#2052](https://github.com/SciML/OrdinaryDiffEq.jl/pull/2052)
