Hi All, I'm running into a problem where Julia is segfaulting when creating a generated method for an existing function. This is the first time I'm using generated functions, so I'm not sure if I'm using it correctly.
function update!(x::Vector{Int}, Δxs::Vector{Int}...) for i in eachindex(x), Δx in Δxs x[i] += Δx[i] end end function update!(x::Vector{Float64}, Δxs::Vector{Float64}...) for i in eachindex(x), Δx in Δxs x[i] += 2.0*Δx[i] end end function update!(sys::Tuple, Δsys::Tuple) for (s, Δs) in zip(sys, Δsys) update!(s, Δs) end end # x = rand(Int, 100); Δx₁ = similar(x), Δx₁ = similar(x) # y = rand(100); Δy₁ = similar(y), Δy₁ = similar(y) # update!(x, Δx₁, Δx₂) # update!(y, Δy₁, Δy₂) # update!((x,y), (Δx₁, Δy₁)) # Want something to handle update!((x,y), (Δx₁, Δy₁), (Δx₂, Δy₂)) @generated function update!{N}(sys::Tuple, Δsys::Vararg{Tuple, N}) # (Δs1, Δs2, ..., ΔsN) el = [Symbol("Δs" * string(i)) for i in 1:N] # zip(Δsys[1], Δsys[2], ..., Δsys[N]) src = Expr(:call, :zip, :sys, [Expr(:ref, :Δsys, i) for i in 1:N]...) quote for $(Expr(:tuple, :s, el...)) in $src # update!(s, Δs1, Δs2, ..., ΔsN) $(Expr(:call, :update!, :s, el...)) end nothing end end signal (11): Segmentation fault while loading no file, in expression starting on line 0 inst_tuple_w_ at /home/darwin/.local/julia/src/jltypes.c:2352 inst_type_w_ at /home/darwin/.local/julia/src/jltypes.c:2437 inst_tuple_w_ at /home/darwin/.local/julia/src/jltypes.c:2383 inst_type_w_ at /home/darwin/.local/julia/src/jltypes.c:2437 jl_instantiate_type_with at /home/darwin/.local/julia/src/jltypes.c:2480 jl_args_morespecific at /home/darwin/.local/julia/src/jltypes.c:3096 jl_typemap_list_insert_sorted at /home/darwin/.local/julia/src/typemap.c:1033 jl_typemap_insert_generic at /home/darwin/.local/julia/src/typemap.c:886 jl_typemap_insert at /home/darwin/.local/julia/src/typemap.c:1006 jl_method_table_insert at /home/darwin/.local/julia/src/gf.c:1069 ⋮ It works fine if I change the name of the generated function to something else. Is this the expected behavior? Thanks, Darwin