Skip to content

Commit 0105fe4

Browse files
authored
Fix inference of max_values(::Union) (#40785)
1 parent 50fa83c commit 0105fe4

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

base/abstractset.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,11 @@ end
8383
max_values(::Type) = typemax(Int)
8484
max_values(T::Union{map(X -> Type{X}, BitIntegerSmall_types)...}) = 1 << (8*sizeof(T))
8585
# saturated addition to prevent overflow with typemax(Int)
86-
max_values(T::Union) = max(max_values(T.a), max_values(T.b), max_values(T.a) + max_values(T.b))
86+
function max_values(T::Union)
87+
a = max_values(T.a)::Int
88+
b = max_values(T.b)::Int
89+
return max(a, b, a + b)
90+
end
8791
max_values(::Type{Bool}) = 2
8892
max_values(::Type{Nothing}) = 1
8993

0 commit comments

Comments
 (0)