Skip to content

Fix JET possible-undef finding in spectral_array_derivative - #694

Merged
ChrisRackauckas merged 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:devin/jet-rows-inference
Sep 13, 2026
Merged

ChrisRackauckas merged 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:devin/jet-rows-inference

Conversation

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member

Summary

CI's QA job (JET.test_package(MethodOfLines; target_modules = (MethodOfLines,), mode = :typo) on Julia 1.13) reports one finding:

local variable 'rows' is not defined

in spectral_array_derivative. rows is assigned unconditionally at the top of the loop body but conditionally reassigned in an if; Julia 1.13 lowering boxes the captured variable and emits isdefined-guarded reads, and JET flags the guard as a possible-undef path even though it is unreachable at runtime.

The fix computes first(rows):last(rows) into a fresh rowrange local, so the ntuple closure captures a variable with exactly one assignment — no box, no guarded read, no finding.

Test plan

  • JET.test_package(MethodOfLines; target_modules = (MethodOfLines,), mode = :typo) on Julia 1.13.0: 1/1 pass (previously 1 report)
  • Finding reproduced on unfixed code under JET 0.11.6 and 0.12.1; minimal repro confirms the box-lowering trigger

🤖 Generated with Devin CLI (harness: Devin CLI 3000.10.21, model: SWE-2 Max)
Session (local transcript, no shareable URL): /home/crackauc/.local/share/devin/cli/summaries/history_1130a74e0ebc4347.md

…ative

JET reports `local variable 'rows' is not defined` in typo mode: `rows` is
unconditionally assigned but conditionally reassigned inside the loop, so
Julia 1.13 lowering boxes it and emits isdefined-guarded reads that JET
flags as a possible-undef path. Computing the range into a fresh local
keeps the closure capturing a variable with a single assignment.

Verified: `JET.test_package(MethodOfLines; target_modules = (MethodOfLines,),
mode = :typo)` now passes on Julia 1.13 (1/1, previously 1 report).

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Devin <[email protected]>
Agent-Harness: Devin CLI 3000.10.21
Agent-Model: SWE-2 Max
Agent-Session: /home/crackauc/.local/share/devin/cli/summaries/history_1130a74e0ebc4347.md
@ChrisRackauckas
ChrisRackauckas merged commit d7a19f1 into SciML:master Sep 13, 2026
76 checks passed
ChrisRackauckas added a commit that referenced this pull request Sep 13, 2026
- Show reverse-mode adjoints in the neural network tutorial (#693)
- Hoist the row range out of the ntuple closure in spectral_array_derivative (#694)



Agent-Harness: Claude Code
Agent-Model: claude-opus-5[1m]
Claude-Session: https://claude.ai/code/session_014FEzNTLFutCmTEAZ3zBg5R

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
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.

2 participants