Skip to content

Julia 1.12 / JET v0.10.7 warns that local variable nadj may be undefined #502

@penelopeysm

Description

@penelopeysm

Hello!

Running JET on SpecialFunctions.logabsgamma (or any function that calls it) leads to an error, specifically on Julia 1.12 and with JET v0.10.7:

julia> using SpecialFunctions, JET

julia> JET.test_call(SpecialFunctions._logabsgamma, (Float64,))
JET-test failed at /Users/pyong/.julia/packages/JET/OqLEC/src/JETBase.jl:1113
  Expression: (JET.report_call)(SpecialFunctions._logabsgamma, (Float64,))
  ═════ 1 possible error found ═════
  ┌ _logabsgamma(x::Float64) @ SpecialFunctions /Users/pyong/ppl/SpecialFunctions.jl/src/logabsgamma/e_lgamma_r.jl:173local variable `nadj` may be undefined: nadj::Float64
  └────────────────────

This occurs because of this line:

if isneg
r = nadj - r
end

I previously reported this on JET (aviatesk/JET.jl#749) and was directed here. The suggestion was to either merge the two if isneg sections (although I don't immediately see how to do this without a slight drop in performance), or to insert @assert @isdefined(nadj) at the bottom to tell the compiler that nadj exists.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions