myop(::Int16, ::Int16) = Int32(1)
myop(::Int16, ::Int32) = Int64(1)
myop(::Int16, ::Int64) = Int128(1)
myop(::Int16, ::Int128) = Int128(1)

foldr(myop, Int16[1]) |> typeof |> println
foldr(myop, Int16[1,1]) |> typeof |> println
foldr(myop, Int16[1,1,1]) |> typeof |> println
foldr(myop, Int16[1,1,1,1]) |> typeof |> println
 

gives


Int32
Int64
Int128
Int128

Would it be better if the answer was typestable (always Int128)? See also 
here <https://github.com/JuliaLang/julia/issues/18960>.

Reply via email to