JuliaArrays / JuliaArrays/StaticArrays.jl

Stack overflow from loop in FieldVector constructor with mismatched types

Open
#375 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Julia
Stars
844
Forks
159
Avg merge
3d 21h
Merged PRs (30d)
3

Description

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: https://github.com/JuliaDiff/ForwardDiff.jl/pull/307/commits/d953ba0e47f3cfbb4cf7428f0d2add912b7d730e#diff-30d7dfc19018c9a0eb3e06548b8d98eeR185 can cause a stack overflow because of this. (JuliaDiff/ForwardDiff.jl#307)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the FieldVector constructor and compare its mixed-type behavior with SVector, using the Point example as the reproducer. Determine whether promotion can be supported without a design conflict, and consider the ForwardDiff.jl case as an additional regression scenario; done means mismatched numeric types no longer cause a stack overflow.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.