Skip to content

Commit

Permalink
Fix inference of max_values(::Union) (#40785)
Browse files Browse the repository at this point in the history
(cherry picked from commit 0105fe4)
  • Loading branch information
odow authored and staticfloat committed Dec 22, 2022
1 parent fc82e63 commit c2a829c
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 @@ -81,7 +81,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 c2a829c

Please sign in to comment.