I started using JET.jl recently. In most cases it is helpful. However, sometimes I just cannot figure out why it has a problem with my code. An example is below. The function foo
is very basic and works fine. Still, JET.jl’s macro @report_call
reports an error. I cannot figure out what it is. What is the best way to identify the problem using the information provided by the macro call?
using DataFrames, JET
df = DataFrame(:A => [1.0, 2.0, 3.0, 4.0])
# 4×1 DataFrame
# Row │ A
# │ Float64
# ─────┼─────────
# 1 │ 1.0
# 2 │ 2.0
# 3 │ 3.0
# 4 │ 4.0
function foo(df::DataFrame)::DataFrame
v = 1:nrow(df)
df[!, :B] = v
return df
end
# foo (generic function with 1 method)
foo(df)
# 4×2 DataFrame
# Row │ A B
# │ Float64 Int64
# ─────┼────────────────
# 1 │ 1.0 1
# 2 │ 2.0 2
# 3 │ 3.0 3
# 4 │ 4.0 4
julia> @report_call foo(df)
═════ 1 possible error found ═════
┌ @ REPL[20]:3 df[:, :B] = v
│┌ @ C:\Users\fsald\.julia\packages\DataFrames\Lrd7K\src\dataframe\dataframe.jl:721 df[DataFrames.:!, col_ind] = DataFrames.copy(v)
││┌ @ C:\Users\fsald\.julia\packages\DataFrames\Lrd7K\src\dataframe\dataframe.jl:669 DataFrames.insert_single_column!(df, v, col_ind)
│││┌ @ C:\Users\fsald\.julia\packages\DataFrames\Lrd7K\src\dataframe\dataframe.jl:653 DataFrames._drop_all_nonnote_metadata!(df)
││││┌ @ C:\Users\fsald\.julia\packages\DataFrames\Lrd7K\src\other\metadata.jl:759 DataFrames._drop_table_nonnote_metadata!(df)
│││││┌ @ C:\Users\fsald\.julia\packages\DataFrames\Lrd7K\src\other\metadata.jl:752 = iterate(metadatakeys(df), getfield(_3, 2))
││││││┌ @ tuple.jl:68 t[i]
│││││││┌ @ tuple.jl:29 Base.getfield(t, i, $(Expr(:boundscheck)))
││││││││ invalid builtin function call