@@ -2592,6 +2592,60 @@ end
25922592
25932593@test map (> :, [Int], [Int]) == [true ]
25942594
2595+ # issue 35566
2596+ module Issue35566
2597+ function step (acc, x)
2598+ xs, = acc
2599+ y = x > 0.0 ? x : missing
2600+ if y isa eltype (xs)
2601+ ys = push! (xs, y)
2602+ else
2603+ ys = vcat (xs, [y])
2604+ end
2605+ return (ys,)
2606+ end
2607+
2608+ function probe (y)
2609+ if y isa Tuple{Vector{Missing}}
2610+ return Val (:missing )
2611+ else
2612+ return Val (:expected )
2613+ end
2614+ end
2615+
2616+ function _foldl_iter (rf, val:: T , iter, state) where {T}
2617+ while true
2618+ ret = iterate (iter, state)
2619+ ret === nothing && break
2620+ x, state = ret
2621+ y = rf (val, x)
2622+ if y isa T
2623+ val = y
2624+ else
2625+ return probe (y)
2626+ end
2627+ end
2628+ return Val (:expected )
2629+ end
2630+
2631+ f () = _foldl_iter (step, (Missing[],), [0.0 ], 1 )
2632+ end
2633+ @test Core. Compiler. typesubtract (Tuple{Union{Int,Char}}, Tuple{Char}, 0 ) == Tuple{Int}
2634+ @test Core. Compiler. typesubtract (Tuple{Union{Int,Char}}, Tuple{Char}, 1 ) == Tuple{Int}
2635+ @test Core. Compiler. typesubtract (Tuple{Union{Int,Char}}, Tuple{Char}, 2 ) == Tuple{Int}
2636+ @test Core. Compiler. typesubtract (NTuple{3 , Union{Int, Char}}, Tuple{Char, Any, Any}, 0 ) ==
2637+ Tuple{Int, Union{Char, Int}, Union{Char, Int}}
2638+ @test Core. Compiler. typesubtract (NTuple{3 , Union{Int, Char}}, Tuple{Char, Any, Any}, 10 ) ==
2639+ Union{Tuple{Int, Char, Char}, Tuple{Int, Char, Int}, Tuple{Int, Int, Char}, Tuple{Int, Int, Int}}
2640+ @test Core. Compiler. typesubtract (NTuple{3 , Union{Int, Char}}, NTuple{3 , Char}, 0 ) ==
2641+ NTuple{3 , Union{Int, Char}}
2642+ @test Core. Compiler. typesubtract (NTuple{3 , Union{Int, Char}}, NTuple{3 , Char}, 10 ) ==
2643+ Union{Tuple{Char, Char, Int}, Tuple{Char, Int, Char}, Tuple{Char, Int, Int}, Tuple{Int, Char, Char},
2644+ Tuple{Int, Char, Int}, Tuple{Int, Int, Char}, Tuple{Int, Int, Int}}
2645+
2646+
2647+ @test Base. return_types (Issue35566. f) == [Val{:expected }]
2648+
25952649# constant prop through keyword arguments
25962650_unstable_kw (;x= 1 ,y= 2 ) = x == 1 ? 0 : " "
25972651_use_unstable_kw_1 () = _unstable_kw (x = 2 )
0 commit comments