Accessing matrix (2x2) at [3] throws an error on master

Sooo, more Optim getting ready for v0.6 material. I fixed the macro problems in Optim fails on v0.6 - #6 by pkofod but the tests still do not pass, as I get the following error

ERROR: LoadError: LoadError: BoundsError: attempt to access 2×2 Array{Float64,2} at index [3]
 in macro expansion at /home/pkm/.julia/v0.6/Optim/src/cg.jl:200 [inlined]
 in macro expansion at ./simdloop.jl:72 [inlined]
 in update_state!(::Optim.DifferentiableFunction, ::Optim.ConjugateGradientState{Float64}, ::Optim.ConjugateGradient{Void}) at /home/pkm/.julia/v0.6/Optim/src/cg.jl:198
 in optimize(::Optim.DifferentiableFunction, ::Array{Float64,2}, ::Optim.ConjugateGradient{Void}, ::Optim.OptimizationOptions{Void}) at /home/pkm/.julia/v0.6/Optim/src/optimize.jl:245

from the lines

@simd for i in 1:state.n
    @inbounds state.y[i] = state.g[i] - state.g_previous[i]
end

I tried adding shows in there, and indeed, when I try to index into the third element of any of the three (y, g, g_previous) 2x2 matrices, it says I’m out of bounds. However, the following examples runs fine

type State
    y
    g
    g_previous
    n
end

the_state = State(rand(2,2), rand(2,2), rand(2,2), 4)

function update!(state)
    @simd for i in 1:state.n
        @inbounds state.y[i] = state.g[i] - state.g_previous[i]
    end
end

update!(the_state)

If I print the types, they are all 2x2 Matrix{Float64,2}'s.

I’m not expecting anyone to go through the code to understand what’s going on, I’m just looking for any good ideas for how to debug this. Thanks

https://github.com/JuliaLang/julia/issues/19554

https://github.com/JuliaLang/julia/pull/19555

Thanks… I’m totally behind the stream of issues these days/weeks/…