JuliaIO / BSON.jl

Other
158 stars 39 forks source link

Error on anonymous functions with keyword arguments #39

Open marius311 opened 5 years ago

marius311 commented 5 years ago

Looks like serializing functions with keyword arguments doesn't work:

julia> using BSON

julia> f = (;x)->x^2
#7 (generic function with 1 method)

julia> BSON.@save "test.bson" f

julia> BSON.@load "test.bson" f

julia> f(x=2)
ERROR: function #7 does not accept keyword arguments
Stacktrace:
 [1] kwfunc(::Any) at ./boot.jl:330
 [2] top-level scope at none:0

Replacing the above with a positional argument works as expected. Would be great if this could be fixed. I would use JLD2 but while that works with keyword arguments, it can't do closures unlike BSON. I'm on Julia 1.1.0 and BSON 0.2.3.

singularitti commented 1 year ago

I am still having this issue today, is there any chance that it could be fixed nowadays?