Skip to content

Rule for foldl fails on empty tuple #672

Open
@mcabbott

Description

@mcabbott

Found here: FluxML/Zygote.jl#1297

julia> using ChainRules, ChainRulesCore, ChainRulesTestUtils

julia> const CFG = ChainRulesTestUtils.TestConfig();

julia> foldl(/, (), init=0)
0

julia> rrule(CFG, foldl, /, (), init=0)
ERROR: BoundsError: attempt to access Tuple{} at index [0]
Stacktrace:
 [1] getindex(t::Tuple, i::Int64)
   @ Base ./tuple.jl:29
 [2] last(a::Tuple{})
   @ Base ./abstractarray.jl:500
 [3] rrule(config::ChainRulesTestUtils.TestConfig, ::typeof(foldl), op::typeof(/), x::Tuple{}; init::Int64)
   @ ChainRules ~/.julia/packages/ChainRules/fgVxV/src/rulesets/Base/mapreduce.jl:448

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions