@@ -144,6 +144,17 @@ optprob.cons_h(H3, x0)
144144 optprob. lag_h (H4, x0, σ, μ)
145145 @test H4≈ σ * H2 + μ[1 ] * H3[1 ] rtol= 1e-6
146146
147+ # Test that the AD-generated lag_hess_prototype has correct dimensions
148+ @test ! isnothing (optprob. lag_hess_prototype)
149+ @test size (optprob. lag_hess_prototype) == (length (x0), length (x0)) # Should be n×n, not num_cons×n
150+
151+ # Test that we can actually use it as a buffer
152+ if ! isnothing (optprob. lag_hess_prototype)
153+ H_proto = similar (optprob. lag_hess_prototype, Float64)
154+ optprob. lag_h (H_proto, x0, σ, μ)
155+ @test H_proto ≈ σ * H2 + μ[1 ] * H3[1 ] rtol= 1e-6
156+ end
157+
147158 G2 = Array {Float64} (undef, 2 )
148159 H2 = Array {Float64} (undef, 2 , 2 )
149160
@@ -257,6 +268,17 @@ optprob.cons_h(H3, x0)
257268 optprob. lag_h (H4, x0, σ, μ)
258269 @test H4≈ σ * H2 + μ[1 ] * H3[1 ] rtol= 1e-6
259270
271+ # Test that the AD-generated lag_hess_prototype has correct dimensions
272+ @test ! isnothing (optprob. lag_hess_prototype)
273+ @test size (optprob. lag_hess_prototype) == (length (x0), length (x0)) # Should be n×n, not num_cons×n
274+
275+ # Test that we can actually use it as a buffer (this would fail with the bug)
276+ if ! isnothing (optprob. lag_hess_prototype)
277+ H_proto = similar (optprob. lag_hess_prototype, Float64)
278+ optprob. lag_h (H_proto, x0, σ, μ)
279+ @test H_proto ≈ σ * H2 + μ[1 ] * H3[1 ] rtol= 1e-6
280+ end
281+
260282 G2 = Array {Float64} (undef, 2 )
261283 H2 = Array {Float64} (undef, 2 , 2 )
262284
490512 optprob. lag_h (H4, x0, σ, μ)
491513 @test H4≈ σ * H1 + sum (μ .* H3) rtol= 1e-6
492514
515+ # Test that the AD-generated lag_hess_prototype has correct dimensions
516+ @test ! isnothing (optprob. lag_hess_prototype)
517+ @test size (optprob. lag_hess_prototype) == (length (x0), length (x0)) # Should be n×n, not num_cons×n
518+
519+ # Test that we can actually use it as a buffer (this would fail with the bug)
520+ if ! isnothing (optprob. lag_hess_prototype)
521+ H_proto = similar (optprob. lag_hess_prototype, Float64)
522+ optprob. lag_h (H_proto, x0, σ, μ)
523+ @test H_proto ≈ σ * H1 + sum (μ .* H3) rtol= 1e-6
524+ end
525+
493526 G2 = Array {Float64} (undef, 2 )
494527 H2 = Array {Float64} (undef, 2 , 2 )
495528
0 commit comments