Problem
src/ADNLPProblems/ADNLPProblems.jl:9 defines:
reshape_array(a, dims) = invoke(Base._reshape, Tuple{AbstractArray, typeof(dims)}, a, dims)
Base._reshape is a private, unexported function. It can be renamed, removed, or change signature across Julia versions without warning. This fragile pattern has silently broken other packages in the past.
The function is used in three problem files: bearing.jl, channel.jl, and marine.jl.
The reason it exists is that AD backends (Zygote, ForwardDiff, etc.) need a reshape that is correctly tracked through the AD graph. Plain reshape sometimes fails to do this, so a custom entry point is needed — but going through Base._reshape via invoke is not the right way to achieve it.
Suggested Fix
Replace invoke(Base._reshape, ...) with a method that AD can overload. A common pattern in the AD ecosystem is:
reshape_array(a, dims) = reshape(a, dims)
with a documented extension point for AD backends, or using ArrayInterface.restructure. Alternatively, check whether Functors.jl or the specific AD backends in use (Zygote, Enzyme) already provide a supported reshape utility.
The fix should be verified against the three affected problems (bearing, channel, marine) using ForwardDiff and Zygote to confirm the AD still works correctly.
Affected files
src/ADNLPProblems/ADNLPProblems.jl (definition)
src/ADNLPProblems/bearing.jl
src/ADNLPProblems/channel.jl
src/ADNLPProblems/marine.jl
References
Found during repository audit (E-SRC-1).
Problem
src/ADNLPProblems/ADNLPProblems.jl:9defines:Base._reshapeis a private, unexported function. It can be renamed, removed, or change signature across Julia versions without warning. This fragile pattern has silently broken other packages in the past.The function is used in three problem files:
bearing.jl,channel.jl, andmarine.jl.The reason it exists is that AD backends (Zygote, ForwardDiff, etc.) need a reshape that is correctly tracked through the AD graph. Plain
reshapesometimes fails to do this, so a custom entry point is needed — but going throughBase._reshapeviainvokeis not the right way to achieve it.Suggested Fix
Replace
invoke(Base._reshape, ...)with a method that AD can overload. A common pattern in the AD ecosystem is:with a documented extension point for AD backends, or using
ArrayInterface.restructure. Alternatively, check whetherFunctors.jlor the specific AD backends in use (Zygote, Enzyme) already provide a supported reshape utility.The fix should be verified against the three affected problems (
bearing,channel,marine) using ForwardDiff and Zygote to confirm the AD still works correctly.Affected files
src/ADNLPProblems/ADNLPProblems.jl(definition)src/ADNLPProblems/bearing.jlsrc/ADNLPProblems/channel.jlsrc/ADNLPProblems/marine.jlReferences
Found during repository audit (E-SRC-1).