Skip to content

Improve static analysis: fix JET errors and add JET tests#117

Merged
ChrisRackauckas merged 1 commit intoSciML:masterfrom
ChrisRackauckas-Claude:static-improvements-20251230-052424
Dec 30, 2025
Merged

Improve static analysis: fix JET errors and add JET tests#117
ChrisRackauckas merged 1 commit intoSciML:masterfrom
ChrisRackauckas-Claude:static-improvements-20251230-052424

Conversation

@ChrisRackauckas-Claude
Copy link
Contributor

Summary

This PR improves static analysis compatibility by fixing type instabilities detected by JET.jl:

  • Fixed find_amsa in math.jl: The function could return false (a Bool) when no AMSA was found, causing similar(false, Type) to fail. Now properly returns nothing and added a type assertion where AMSAStyle guarantees an AMSA exists.
  • Fixed print_human_readable.jl: findfirst and findnext can return Nothing when patterns aren't found. Added proper nil-checks before indexing.
  • Added JET.jl tests: New test/jet_tests.jl runs JET analysis to prevent regressions.

JET analysis now reports 0 errors (was 5 errors before).

Test plan

  • All existing tests pass
  • JET.jl analysis passes with 0 errors
  • CI passes

cc @ChrisRackauckas

🤖 Generated with Claude Code

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>
@ChrisRackauckas ChrisRackauckas merged commit 0e1551a into SciML:master Dec 30, 2025
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants