Skip to content

Commit

Permalink
Fix inference of max_values(::Union) (JuliaLang#40785)
Browse files Browse the repository at this point in the history
  • Loading branch information
odow authored and Amit Shirodkar committed Jun 9, 2021
1 parent a818b9d commit be8fd2c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion base/abstractset.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,11 @@ end
max_values(::Type) = typemax(Int)
max_values(T::Union{map(X -> Type{X}, BitIntegerSmall_types)...}) = 1 << (8*sizeof(T))
# saturated addition to prevent overflow with typemax(Int)
max_values(T::Union) = max(max_values(T.a), max_values(T.b), max_values(T.a) + max_values(T.b))
function max_values(T::Union)
a = max_values(T.a)::Int
b = max_values(T.b)::Int
return max(a, b, a + b)
end
max_values(::Type{Bool}) = 2
max_values(::Type{Nothing}) = 1

Expand Down

0 comments on commit be8fd2c

Please sign in to comment.