-
Notifications
You must be signed in to change notification settings - Fork 151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Usage of parametrized FieldVector can lead to StackOverflowError #968
Comments
You could just define |
Hmm, interesting. That inner constructor seems wrong to me. I don’t have Julia to check what it should be right now, but type selection and conversion should happen separately. (There’s the tuple constructor and similar_type and so-on that also need to work.) |
Thank you very much and sorry for the long delay, I didn't get around to test your suggestion. It works perfectly fine now, except for the last line (but as you said, this isn't supposed to work anyway). Just for reference, here is the code again with your suggestion included. using StaticArrays
struct Point2D{T} <: FieldVector{2,T}
x::T
y::T
Point2D(x,y) = new{eltype(x)}(x,y)
end
Point2D{T}(x::T,y) where T = Point2D(x,y)
point1 = Point2D(0.0, 0.0)
point2 = Point2D(1.0, 0.0)
vec = [point1, point2]
point3 = Point2D(2.0, 0.0)
# This works
vec[2] = Point2D(2.0, 0.0)
# ==============================================================================
# Those examples now all work
vec[2] ≈ point3
test = point1 .+ point3
test = vec[2] .+ point3 |
Hello,
I found quite some ways to produce
StackOverflowError
when dealing with a parametrizedFieldVector
type:I kind of expected the last use case to fail, since I'm trying to add a
Point2D{Int}
to a vector of typePoint2D{Float64}
. However, the other use cases I expected to work. Is this a bug or should a user define corresponding functions for any of those use cases?I should add that all of the shown use cases work fine when using a non-parametrized
FieldVector
.The text was updated successfully, but these errors were encountered: