Improve static analysis: fix JET errors and add JET tests#117
Merged
ChrisRackauckas merged 1 commit intoSciML:masterfrom Dec 30, 2025
Merged
Conversation
This PR addresses type instabilities detected by JET.jl analysis: **JET issues fixed:** 1. `math.jl`: Fixed `find_amsa` function returning `false` instead of a proper type - Changed fallback to return `nothing` instead of propagating non-AMSA values - Added type assertion in `copy` to inform the compiler that AMSAStyle guarantees an AMSA exists - Added explicit method `find_amsa(x::AMSA) = x` for direct dispatch - Added `find_amsa(::Nothing, rest)` to handle the nothing case properly 2. `print_human_readable.jl`: Fixed potential `nothing` indexing errors - `findfirst` and `findnext` can return `nothing` when pattern not found - Added proper nil-checks before indexing into results **New tests added:** - Added `test/jet_tests.jl` with JET.jl static analysis test - Added JET as a test dependency in Project.toml All existing tests pass with these changes. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
This PR improves static analysis compatibility by fixing type instabilities detected by JET.jl:
find_amsainmath.jl: The function could returnfalse(a Bool) when no AMSA was found, causingsimilar(false, Type)to fail. Now properly returnsnothingand added a type assertion where AMSAStyle guarantees an AMSA exists.print_human_readable.jl:findfirstandfindnextcan returnNothingwhen patterns aren't found. Added proper nil-checks before indexing.test/jet_tests.jlruns JET analysis to prevent regressions.JET analysis now reports 0 errors (was 5 errors before).
Test plan
cc @ChrisRackauckas
🤖 Generated with Claude Code