Skip to content

Commit

Permalink
Merge pull request #542 from raphaelchinchilla/return_tuples
Browse files Browse the repository at this point in the history
Included dispatch to toexpr that creates Tuples correctly
  • Loading branch information
shashi authored Aug 20, 2023
2 parents 91879dd + 564ba54 commit e4812a3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/code.jl
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ function toexpr(O, st)
end
end

function toexpr(O::Tuple, st)
:(($(toexpr.(O, (st,))...),))
end

# Call elements of vector arguments by their name.
@matchable struct DestructuredArgs
elems
Expand Down
2 changes: 2 additions & 0 deletions test/code.jl
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ nanmath_st.rewrites[:nanmath] = true
:(SparseVector(10, $(spvec.nzind), [a])))
test_repr(toexpr(MakeTuple((a, b, a+b))),
:((a,b,$(+)(a,b))))
test_repr(toexpr((a, b, a+b)),
:((a,b,$(+)(a,b))))

@test SpawnFetch{Multithreaded}([()->1,()->2],vcat)|>toexpr|>eval == [1,2]
@test @elapsed(SpawnFetch{Multithreaded}([:(()->sleep(2)),
Expand Down

0 comments on commit e4812a3

Please sign in to comment.