Skip to content
This repository was archived by the owner on May 12, 2026. It is now read-only.
This repository was archived by the owner on May 12, 2026. It is now read-only.

StackOverflowError when adding an structure inside DEDataVector in a Module #526

@ronisbr

Description

@ronisbr

Hi! With the following code:

module MyTest2

using ArrayInterface

export A
struct A{T}
    a::T
end

ArrayInterface.ismutable(::Type{<:A}) = true

using RecursiveArrayTools
using OrdinaryDiffEq
using DiffEqBase

export Workspace
mutable struct Workspace{T} <: DEDataVector{T}
    x::Vector{T}
    a::A{T}
end

export test
function test()
    w1 = Workspace(zeros(3), A(0.0))
    w2 = Workspace(zeros(3), A(0.0))
    return RecursiveArrayTools.recursivecopy!(w1,w2)
end

end

I am getting the following error when calling the function test():

julia> test()
ERROR: StackOverflowError:
Stacktrace:
 [1] ismutable(::Type{T} where T) at /Users/ronan.arraes/.julia/packages/ArrayInterface/YFV07/src/ArrayInterface.jl:19 (repeats 79978 times)

I think it is related to the @generated function recursivecopy!. Because, this code works outside a module:

using ArrayInterface

struct A{T}
    a::T
end

ArrayInterface.ismutable(::Type{<:A}) = false

using RecursiveArrayTools
using OrdinaryDiffEq
using DiffEqBase

mutable struct Workspace{T} <: DEDataVector{T}
    x::Vector{T}
    a::A{T}
end

function test()
    w1 = Workspace(zeros(3), A(0.0))
    w2 = Workspace(zeros(3), A(0.0))
    return RecursiveArrayTools.recursivecopy!(w1,w2)
end
julia> test()
3-element Workspace{Float64}:
 0.0
 0.0
 0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions