@@ -307,7 +307,7 @@ generated thunks.
307307macro par (exs... )
308308 opts = exs[1 : end - 1 ]
309309 ex = exs[end ]
310- return esc (_par (ex; lazy= true , opts= opts))
310+ return esc (_par (__module__, ex; lazy= true , opts= opts))
311311end
312312
313313"""
@@ -349,7 +349,7 @@ also passes along any options in an `Options` struct. For example,
349349macro spawn (exs... )
350350 opts = exs[1 : end - 1 ]
351351 ex = exs[end ]
352- return esc (_par (ex; lazy= false , opts= opts))
352+ return esc (_par (__module__, ex; lazy= false , opts= opts))
353353end
354354
355355struct ExpandedBroadcast{F} end
365365
366366to_namedtuple (;kwargs... ) = (;kwargs... )
367367
368- function _par (ex:: Expr ; lazy= true , recur= true , opts= ())
368+ function _par (mod, ex:: Expr ; lazy= true , recur= true , opts= ())
369369 f = nothing
370+ bf = nothing
370371 body = nothing
371372 arg1 = nothing
372373 arg2 = nothing
@@ -375,7 +376,11 @@ function _par(ex::Expr; lazy=true, recur=true, opts=())
375376 @capture (ex, allargs__-> body_) ||
376377 @capture (ex, arg1_[allargs__]) ||
377378 @capture (ex, arg1_. arg2_) ||
378- @capture (ex, (;allargs__))
379+ @capture (ex, (;allargs__)) ||
380+ @capture (ex, bf_ .(allargs__))
381+ if bf != = nothing
382+ f = ExpandedBroadcast {mod.eval(bf)} ()
383+ end
379384 f = replace_broadcast (f)
380385 if arg1 != = nothing
381386 if arg2 != = nothing
@@ -429,15 +434,15 @@ function _par(ex::Expr; lazy=true, recur=true, opts=())
429434 end
430435 elseif lazy
431436 # Recurse into the expression
432- return Expr (ex. head, _par_inner .(ex. args, lazy= lazy, recur= recur, opts= opts)... )
437+ return Expr (ex. head, _par_inner .(Ref (mod), ex. args, lazy= lazy, recur= recur, opts= opts)... )
433438 else
434439 throw (ArgumentError (" Invalid Dagger task expression: $ex " ))
435440 end
436441end
437- _par (ex; kwargs... ) = throw (ArgumentError (" Invalid Dagger task expression: $ex " ))
442+ _par (mod, ex; kwargs... ) = throw (ArgumentError (" Invalid Dagger task expression: $ex " ))
438443
439- _par_inner (ex; kwargs... ) = ex
440- _par_inner (ex:: Expr ; kwargs... ) = _par (ex; kwargs... )
444+ _par_inner (mod, ex; kwargs... ) = ex
445+ _par_inner (mod, ex:: Expr ; kwargs... ) = _par (mod, ex; kwargs... )
441446
442447"""
443448 Dagger.spawn(f, args...; kwargs...) -> DTask
0 commit comments