Skip to content

Commit 95612d0

Browse files
authored
fix iterate(@thunk ()) (#534)
1 parent d9f4a44 commit 95612d0

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ChainRulesCore"
22
uuid = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
3-
version = "1.11.4"
3+
version = "1.11.5"
44

55
[deps]
66
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"

src/tangent_types/thunks.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ Base.Broadcast.broadcastable(x::AbstractThunk) = broadcastable(unthunk(x))
1111

1212
@inline function Base.iterate(x::AbstractThunk)
1313
val = unthunk(x)
14-
element, state = iterate(val)
14+
el_and_state = iterate(val)
15+
el_and_state isa Nothing && return nothing
16+
element, state = el_and_state
1517
return element, (val, state)
1618
end
1719

test/tangent_types/thunks.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
for (i, j) in zip(a, t)
1616
@test i == j
1717
end
18+
19+
@test nothing === iterate(@thunk ()) == iterate(())
1820
end
1921

2022
@testset "show" begin

0 commit comments

Comments
 (0)