Skip to content

Stack overflow from loop in FieldVector constructor with mismatched types #375

Open
@zsunberg

Description

@zsunberg
struct Point{R<:Real} <: FieldVector{2, R}
x::R
y::R
end

Point(1.0, 2)

currently causes a stack overflow (because it tries to construct a Point with a Float64 and an Int).

SVector currently handles this by promoting the arguments. Should FieldVector do something similar, or is there a fundamental issue with the design of FieldVector that prevents this?

This can cause confusing errors, e.g. calculating the jacobian with ForwardDiff of the function here: JuliaDiff/ForwardDiff.jl@d953ba0#diff-30d7dfc19018c9a0eb3e06548b8d98eeR185 can cause a stack overflow because of this. (JuliaDiff/ForwardDiff.jl#307)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions