@@ -371,10 +371,12 @@ function _par(mod, ex::Expr; lazy=true, recur=true, opts=())
371371 body = nothing
372372 arg1 = nothing
373373 arg2 = nothing
374+ value = nothing
374375 if recur && @capture (ex, f_ (allargs__)) ||
375376 @capture (ex, f_ (allargs__) do cargs_ body_ end ) ||
376377 @capture (ex, allargs__-> body_) ||
377378 @capture (ex, arg1_[allargs__]) ||
379+ @capture (ex, arg1_[allargs__] = value_) ||
378380 @capture (ex, arg1_. arg2_) ||
379381 @capture (ex, (;allargs__)) ||
380382 @capture (ex, bf_ .(allargs__))
@@ -387,8 +389,13 @@ function _par(mod, ex::Expr; lazy=true, recur=true, opts=())
387389 # Getproperty (A.B)
388390 f = Base. getproperty
389391 allargs = Any[arg1, QuoteNode (arg2)]
392+ elseif value != = nothing
393+ # setindex! (A[2,3] = 4)
394+ f = _setindex!_return_value
395+ pushfirst! (allargs, value)
396+ pushfirst! (allargs, arg1)
390397 else
391- # Indexing (A[2,3])
398+ # getindex (A[2,3])
392399 f = Base. getindex
393400 pushfirst! (allargs, arg1)
394401 end
@@ -444,6 +451,11 @@ _par(mod, ex; kwargs...) = throw(ArgumentError("Invalid Dagger task expression:
444451_par_inner (mod, ex; kwargs... ) = ex
445452_par_inner (mod, ex:: Expr ; kwargs... ) = _par (mod, ex; kwargs... )
446453
454+ function _setindex!_return_value (A, value, idxs... )
455+ setindex! (A, value, idxs... )
456+ return value
457+ end
458+
447459"""
448460 Dagger.spawn(f, args...; kwargs...) -> DTask
449461
0 commit comments