JuliaLang / Distributed.jl

Create and control multiple Julia processes remotely for distributed computing. Ships as a Julia stdlib.
https://docs.julialang.org/en/v1/stdlib/Distributed/
MIT License
20 stars 8 forks source link

Error when using functions with kwargs #104

Open pablosanjose opened 1 week ago

pablosanjose commented 1 week ago

This fails since at least 1.6 up until nightly

using Distributed
addprocs(1)
@everywhere begin
    f1 = o -> o
    f2 = (o, m=1) -> o
    fbad = (o; m=1) -> o
end
remotecall_fetch(f1, 1, 1)   # 1
remotecall_fetch(f2, 1, 1)   # 1
remotecall_fetch(fbad, 1, 1) # 1
remotecall_fetch(f1, 2, 1)   # 1
remotecall_fetch(f2, 2, 1)   # 1
remotecall_fetch(fbad, 2, 1) # errors!

The error of the last call is

ERROR: On worker 2:
MethodError: no method matching var"#3#4"(::Int64, ::Serialization.__deserialized_types__.var"#3#7", ::Int64)
The function `#3#4` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  var"#3#4"(::Any, ::var"#3#7", ::Any) (method too new to be called from this world context.)
   @ Main REPL[3]:4

Stacktrace:
 [1] #3
   @ ./none:-1 [inlined]
 [2] #3
   @ ./REPL[3]:0
 [3] #invokelatest#2
   @ ./essentials.jl:1045
 [4] invokelatest
   @ ./essentials.jl:1042
 [5] #110
   @ ~/.julia/juliaup/julia-nightly/share/julia/stdlib/v1.12/Distributed/src/process_messages.jl:287
 [6] run_work_thunk
   @ ~/.julia/juliaup/julia-nightly/share/julia/stdlib/v1.12/Distributed/src/process_messages.jl:70
 [7] #109
   @ ~/.julia/juliaup/julia-nightly/share/julia/stdlib/v1.12/Distributed/src/process_messages.jl:287
Stacktrace:
 [1] remotecall_fetch(f::Function, w::Distributed.Worker, args::Int64; kwargs::@Kwargs{})
   @ Distributed ~/.julia/juliaup/julia-nightly/share/julia/stdlib/v1.12/Distributed/src/remotecall.jl:465
 [2] remotecall_fetch(f::Function, w::Distributed.Worker, args::Int64)
   @ Distributed ~/.julia/juliaup/julia-nightly/share/julia/stdlib/v1.12/Distributed/src/remotecall.jl:454
 [3] remotecall_fetch(f::Function, id::Int64, args::Int64)
   @ Distributed ~/.julia/juliaup/julia-nightly/share/julia/stdlib/v1.12/Distributed/src/remotecall.jl:492
 [4] top-level scope
   @ REPL[9]:1