Skip to content

eltype could be more accurate for Iterators.flatten #48249

@gaurav-arya

Description

@gaurav-arya

On julia 1.9.0-beta2, I'm observing the following behaviour when using Iterators.flatten to concatenate two iterators of integers:

julia> iter = Iterators.flatten(((3,), [4, 5]))
Base.Iterators.Flatten{Tuple{Tuple{Int64}, Vector{Int64}}}(((3,), [4, 5]))

julia> eltype(iter)
Any

It feels like this could be improved? If all the concatenated iterators have eltype of Int64, then shouldn't iter too?

I'm happy to make a PR for this if I'm not missing something and this indeed could be impoved. Version info:

julia> versioninfo()
Julia Version 1.9.0-beta2
Commit 7daffeecb8c (2022-12-29 07:45 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 8 × 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-14.0.6 (ORCJIT, tigerlake)
  Threads: 1 on 8 virtual cores
Environment:
  JULIA_EDITOR = code
  JULIA_NUM_THREADS = 

Metadata

Metadata

Assignees

No one assigned

    Labels

    compiler:inferenceType inferenceiterationInvolves 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