Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix some type instabilities introduced by #39607
After #39607, `Iterators.peel` can return `nothing` and the return type can be more inaccurate than before for certain iterative inputs where inference doesn't understand its length, e.g. `Iterators.peel(::<:AbstractString)`. The following JET analysis shows an example of this type instability: ```julia ═════ 2 possible errors found ═════ ┌ @ coreio.jl:4 Base.println(Core.tuple(Core.typeassert(Base.stdout, Base.IO)), xs...) │┌ @ strings/io.jl:73 Base.print(Core.tuple(io), xs, Core.tuple("\n")...) ││┌ @ strings/io.jl:46 Base.print(io, x) │││┌ @ show.jl:1283 Base.show_unquoted(Base.IOContext(io, Base.=>(:unquote_fallback, false)), ex, 0, -1) ││││┌ @ show.jl:1634 Base.show_unquoted_quote_expr(io, Base.getproperty(ex, :value), indent, prec, 0) │││││┌ @ show.jl:1651 Base.isidentifier(sym) ││││││┌ @ show.jl:1339 Base.isidentifier(Base.string(s)) │││││││┌ @ show.jl:1335 Base.indexed_iterate(Base.Iterators.peel(s), 1) ││││││││┌ @ tuple.jl:92 Base.iterate(I) │││││││││ no matching method found for call signature (Tuple{typeof(iterate), Nothing}): Base.iterate(I::Nothing) ││││││││└─────────────── │││││││┌ @ show.jl:1335 Base.indexed_iterate(Base.Iterators.peel(s), 2, _3) ││││││││┌ @ tuple.jl:97 Base.iterate(I, state) │││││││││ no matching method found for call signature (Tuple{typeof(iterate), Nothing, Int64}): Base.iterate(I::Nothing, state::Int64) ││││││││└─────────────── Core.Const(nothing) ``` This PR adds code refactors or manual annotations and seems to fix some of regressions within Base.
- Loading branch information