Why do I get this error in JET.jl

Hi all :slight_smile:

I’m using that awesome tool JET. It works well, but I get the following error - don’t understand why

julia> JET.@report_call Dict{String, String}(string(k) => v for (k,v) in enumerate(["1", "2"]))
═════ 2 possible errors found ═════
β”Œ @ dict.jl:104 h[k] = v
β”‚β”Œ @ dict.jl:382 v = convert(V, v0)
β”‚β”‚ no matching method found `convert(::Type{String}, ::Int64)`: v = convert(V::Type{String}, v0::Int64)
│└───────────────
β”Œ @ dict.jl:105  = iterate(kv, getfield(_3, 2))
β”‚β”Œ @ generator.jl:44 y = iterate(tuple(g.iter), s...)
β”‚β”‚β”Œ @ iterators.jl:167 n = Base.Iterators.iterate(tuple(e.itr), rest...)
β”‚β”‚β”‚β”Œ @ array.jl:898 i % Base.UInt
β”‚β”‚β”‚β”‚ no matching method found `rem(::String, ::Type{UInt64})`: (i::String % Base.UInt)
│││└────────────────

Thanks

Could you try editing your line to string(k::Int)? My guess is that inference gives up somewhere and it fails to learn that k is Int, so you need to tell it so manually.

For what is worth, it seems this particular inference imperfection is fixed on the current nightly branch. I did not get any problems reported on it for your code snippet. This is why I mostly test with JET only on the latest julia version (inference is still getting rapidly better).

When you see something like this in your code (1) you can fix it immediately by telling Julia what the type is and (2) submit a github issue so that devs can make Julia’s inference pass smarter. Generally the JET developer is very grateful for this type of issue reports. It is what they use to make Julia’s inference better.

1 Like

ty I’ll try it later!

I tried it now with the dev version and it’s fixed