Skip to content

regression in master: different return type and type instability in count #59869

@matthias314

Description

@matthias314

In Julia 1.12.0, the return type of count is the type of init, if present:

julia> count(iszero, Int[]; init=Int8(0)) |> typeof
Int8

julia> count(iszero, Int[1]; init=Int8(0)) |> typeof
Int8

julia> count(Bool[]; init=Int8(0)) |> typeof
Int8

julia> count(Bool[1]; init=Int8(0)) |> typeof
Int8

For master this is not the case anymore. In particular, there is now a type instability:

julia> count(iszero, Int[]; init=Int8(0)) |> typeof
Int8

julia> count(iszero, Int[1]; init=Int8(0)) |> typeof
Int64

julia> count(Bool[]; init=Int8(0)) |> typeof
Int64

julia> count(Bool[1]; init=Int8(0)) |> typeof
Int64
Julia Version 1.13.0-DEV.1323
Commit c4f28781319 (2025-10-16 18:54 UTC)
Build Info:
  Official https://julialang.org release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 4 × Intel(R) Core(TM) i3-10110U CPU @ 2.10GHz
  WORD_SIZE: 64
  LLVM: libLLVM-20.1.8 (ORCJIT, skylake)
  GC: Built with stock GC

Metadata

Metadata

Assignees

No one assigned

    Labels

    foldsum, maximum, reduce, foldl, etc.regressionRegression in behavior compared to a previous version

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions