Skip to content

Commit

Permalink
fix: reducing over empty collection
Browse files Browse the repository at this point in the history
  • Loading branch information
avik-pal committed Jul 28, 2024
1 parent 2eddcb7 commit 3c6b131
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Functors"
uuid = "d9f16b24-f501-4c13-a1f2-28368ffc5196"
authors = ["Mike J Innes <mike.j.innes@gmail.com>"]
version = "0.4.11"
version = "0.4.12"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand Down
2 changes: 1 addition & 1 deletion src/walks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,6 @@ function (walk::FlattenWalk)(recurse, x, ys...)
x_children = _values(children(x))
ys_children = map(children, ys)
res = _map(recurse, x_children, ys_children...)
return reduce(vcat, _values(res))
return reduce(vcat, _values(res); init = [])
end

3 changes: 3 additions & 0 deletions test/basics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,9 @@ end
@test xflat isa Vector
@test length(xflat) == 3
@test 1 xflat && 2 xflat && [1, 2, 3] xflat

@test fleaves((;)) == []
@test fleaves((; a = 1, b = 2, c = (;))) == [1, 2]
end

@testset "fmap_with_path" begin
Expand Down

0 comments on commit 3c6b131

Please sign in to comment.