Add JET.jl static analysis tests and fix type instabilities #1131
+25
−7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Changes
Bug Fixes
filled_spadin adtypes.jl: Added missingelseclause that caused implicitnothingreturn when bothsparsity_detectorandcoloring_algorithmwere already set. This could cause downstream type instabilities.__solve(cache::AbstractOptimizationCache)in solve.jl: Replaced empty function body with properArgumentErrorthrow. The previous implementation returnednothingimplicitly which violated the return type annotation and caused JET to report a type conversion error.instantiate_functionerror path in function.jl: Fixed handling of edge case where bothfindfirst('(', ...)andfindfirst('{', ...)returnnothing, which would causenothing - 1to fail at runtime.New Tests
test/qa.jlthat runsJET.report_packageon the Optimization module and asserts zero errorsJET Analysis Results
After these fixes:
The remaining 11 errors in OptimizationBase are not real bugs - they occur because JET cannot track the relationship between conditional checks for
f.cons !== nothingand the definitions ofcons_oop/lagrangianvariables. At runtime, these code paths are always guarded correctly.Test Plan
cc @ChrisRackauckas
🤖 Generated with Claude Code