Skip to content

Fix JET-flagged may-be-undefined locals failing QA CI#46

Merged
ChrisRackauckas merged 1 commit into
SciML:mainfrom
ChrisRackauckas-Claude:fix-jet-undefined-locals
Jun 16, 2026
Merged

Fix JET-flagged may-be-undefined locals failing QA CI#46
ChrisRackauckas merged 1 commit into
SciML:mainfrom
ChrisRackauckas-Claude:fix-jet-undefined-locals

Conversation

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Contributor

What

Fixes the failing QA CI on main. The QA group's JET linting (JET.test_package, added in #40) reports four "local variable may be undefined" errors and fails the tests / QA (julia 1) lane:

_parse_head(head::Expr) @ src/ConcreteStructs.jl:198
  local variable `struct_name` may be undefined
  local variable `type_params` may be undefined
  local variable `super` may be undefined
_parse_line(line::Expr) @ src/ConcreteStructs.jl:228
  local variable `val` may be undefined

These are genuine latent issues in the source, surfaced by the JET lint check that was newly added to the QA group; they are not fixed by skipping/loosening anything.

Fix (3 lines, behavior-preserving)

  • _parse_head(head::Expr) — the if head.head === :curly / elseif === :(<:) chain had no fallthrough, so for any other head the three returned locals were undefined. Added an else that error("Invalid usage of @concrete."), matching the existing invalid-usage handling in _find_struct_def/_apply_original_expr. This makes the function total and clears three findings.
  • _parse_line(line::Expr)val was assigned only inside if assignment, but its binding is read at the later if assignment ? ... : ... site, which JET cannot prove reachable-only-when-defined. Initialized val = nothing next to the existing annotation = nothing. No behavior change: val is only read when assignment is true.

Local verification

  • Julia 1.12 (CI's julia 1), QA sub-env: Aqua 11/11 and JET 1/1 pass, zero JET findings.
  • Julia 1.10 (compat floor), Core group: 40/40 pass, including the invalid-usage assertion.
  • Runic --check on src/ConcreteStructs.jl: clean (exit 0).

Please ignore until reviewed by @ChrisRackauckas.

The QA group's JET linting (added in SciML#40) reports four "local variable
may be undefined" errors that fail CI on main:

- `_parse_head(head::Expr)`: the `if/elseif` over `head.head` had no
  fallthrough, so `struct_name`, `type_params`, and `super` were
  undefined for any other head. Add an `else` that errors, matching the
  existing invalid-usage handling elsewhere in the file. This makes the
  function total and removes three of the JET findings.
- `_parse_line(line::Expr)`: `val` was bound only inside `if assignment`
  but its binding is visible at the later `if assignment` read site, so
  JET cannot prove it defined. Initialize `val = nothing` alongside the
  existing `annotation = nothing`; behavior is unchanged since `val` is
  only read when `assignment` is true.

Verified locally on Julia 1.12 (CI's `julia 1`): the QA group now passes
(Aqua 11/11, JET 1/1, zero findings). Core group still passes 40/40 on
Julia 1.10, including the invalid-usage assertion.

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@ChrisRackauckas ChrisRackauckas marked this pull request as ready for review June 16, 2026 08:52
@ChrisRackauckas ChrisRackauckas merged commit ddbc6bf into SciML:main Jun 16, 2026
11 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.

2 participants