aviatesk / JET.jl

An experimental code analyzer for Julia. No need for additional type annotations.
https://aviatesk.github.io/JET.jl/dev/
MIT License
722 stars 29 forks source link

false positive: InferenceErrorReport on @kwdef parametrized struct #563

Open dpinol opened 11 months ago

dpinol commented 11 months ago

A false positive is reported by JET 0.8.12 (also in 0.8.14) which did not appear on 0.8.11. Reproducible in julia 1.9.3 & 1.10.0beta3

module ParametrizedKwdef

    Base.@kwdef mutable struct ST{O <: Number}
        sum::O = zero(O)
    end
end # module ParametrizedKwdef

I attach full project ParametrizedKwdef.zip

julia> JET.report_package("ParametrizedKwdef")
[toplevel-info] virtualized the context of Main (took 0.009 sec)
[toplevel-info] entered into /home/dani/dev/julia/jet/issues/ParametrizedKwdef/src/ParametrizedKwdef.jl
[toplevel-info]  exited from /home/dani/dev/julia/jet/issues/ParametrizedKwdef/src/ParametrizedKwdef.jl (took 0.328 sec)
[toplevel-info] analyzing from top-level definitions (8/8)
[toplevel-info] analyzed 8 top-level definitions (took 0.479 sec)
═════ 2 possible errors found ═════
┌ ParametrizedKwdef.ST() @ ParametrizedKwdef ./util.jl:578
│ `ParametrizedKwdef.O` is not defined: ParametrizedKwdef.zero(ParametrizedKwdef.O)
└────────────────────
┌ kwcall(::Any, ::Type{ParametrizedKwdef.ST}) @ ParametrizedKwdef ./util.jl:578
│ `ParametrizedKwdef.O` is not defined: @_5 = ParametrizedKwdef.zero(ParametrizedKwdef.O)
dpinol commented 5 months ago

Hi, any news about this? It still occurs in julia 1.10 and JET v0.8.29

thanks