Skip to content

length() no longer works with Iterators.Stateful in Julia 1.11rc1 #54953

@s-fuerst

Description

@s-fuerst

In Julia 1.10, the following code works as expected:

julia> length(Iterators.Stateful([1,2,3]))
3

However, in Julia 1.11rc1, the same code fails with this error message:

MethodError: no method matching length(::Base.Iterators.Stateful{Vector{Int64}, Union{Nothing, Tuple{Int64, Int64}}})

This change in behavior appears to be unintended and breaks existing code that relies on being able to get the length of a Stateful iterator.

Steps to reproduce:

  1. Install Julia 1.11rc1
  2. Run the code: length(Iterators.Stateful([1,2,3]))

Expected behavior: Returns 3
Actual behavior: MethodError: no method matching length(::Base.Iterators.Stateful{Vector{Int64}, Union{Nothing, Tuple{Int64, Int64}}})

System information:

  • Julia version: 1.11rc1
  • OS: Linux Mint 21
  • Architecture: x86_64

Metadata

Metadata

Assignees

No one assigned

    Labels

    iterationInvolves iteration or the iteration protocol

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions