Skip to content

fix: reducing over empty collection #87

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading