Why does JET.jl has a problem with adding a column to a dataframe?

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 macto @report_call reports an error. What is happening?

(@v1.8) pkg> activate --temp
  Activating new project at `C:\Users\fsald\AppData\Local\Temp\jl_774bEc`

(jl_774bEc) pkg> add DataFrames JET
# Info omitted here

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

@report_call foo(df)
# ═════ 1 possible error found ═════
# β”Œ @ REPL[15]:3 df[!, :B] = 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
1 Like

you can’t not tell us what is foo…

Sorry, I skipped it while cutting and pasting. The edited question now has a definition for foo.