diff --git a/src/scimlfunctions.jl b/src/scimlfunctions.jl index 5c4ec2d04..2dc18cab2 100644 --- a/src/scimlfunctions.jl +++ b/src/scimlfunctions.jl @@ -4279,7 +4279,6 @@ function OptimizationFunction{iip}(f, adtype::AbstractADType = NoAD(); lag_hess_colorvec = nothing, initialization_data = __has_initialization_data(f) ? f.initialization_data : nothing) where {iip} - isinplace(f, 2; has_two_dispatches = false, isoptimization = true) sys = sys_or_symbolcache(sys, syms, paramsyms) OptimizationFunction{ iip, typeof(adtype), typeof(f), typeof(grad), typeof(fg), typeof(hess), diff --git a/test/function_building_error_messages.jl b/test/function_building_error_messages.jl index f07c9fc62..8031ef697 100644 --- a/test/function_building_error_messages.jl +++ b/test/function_building_error_messages.jl @@ -507,6 +507,14 @@ optf(u, p) = 1.0 OptimizationFunction(optf) OptimizationProblem(optf, 1.0) +# Test OptimizationFunction{iip} respects explicit iip parameter +# This function would fail isinplace check due to method ambiguity +struct ProblematicOptFunction end +(::ProblematicOptFunction)(x, p) = sum(x .^ 2) +# But when iip is explicitly provided, it should work without calling isinplace +@test_nowarn OptimizationFunction{false}(ProblematicOptFunction()) +@test_nowarn OptimizationFunction{true}(ProblematicOptFunction()) + # BVPFunction bfoop(u, p, t) = u