Skip to content

Commit c93f12f

Browse files
committed
fix: promote vs to a Union{Bool, ...} whenever a boolean value is present
1 parent a69570a commit c93f12f

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/utils.jl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,7 @@ function promote_to_concrete(vs; tofloat = true, use_union = false)
680680
I = Int8
681681
has_int = false
682682
has_array = false
683+
has_bool = false
683684
array_T = nothing
684685
for v in vs
685686
if v isa AbstractArray
@@ -692,16 +693,22 @@ function promote_to_concrete(vs; tofloat = true, use_union = false)
692693
has_int = true
693694
I = promote_type(I, E)
694695
end
696+
if E <: Bool
697+
has_bool = true
698+
end
695699
end
696-
if tofloat && !has_array
700+
if tofloat && !has_array && !has_bool
697701
C = float(C)
698-
elseif has_array || (use_union && has_int && C !== I)
702+
elseif has_array || (use_union && has_int && C !== I) || has_bool
699703
if has_array
700704
C = Union{C, array_T}
701705
end
702706
if has_int
703707
C = Union{C, I}
704708
end
709+
if has_bool
710+
C = Union{C, Bool}
711+
end
705712
return copyto!(similar(vs, C), vs)
706713
end
707714
convert.(C, vs)

0 commit comments

Comments
 (0)