Skip to content

Commit f4c23df

Browse files
KenoJeffBezanson
andauthored
Fix real(Complex{<:AbstractFloat}) (#33107)
Co-Authored-By: Jeff Bezanson <[email protected]>
1 parent 942021c commit f4c23df

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

base/complex.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ Float64
108108
"""
109109
real(T::Type) = typeof(real(zero(T)))
110110
real(::Type{T}) where {T<:Real} = T
111-
real(::Type{Complex{T}}) where {T<:Real} = T
111+
real(C::Type{<:Complex}) = fieldtype(C, 1)
112112

113113
"""
114114
isreal(x) -> Bool

test/complex.jl

+3
Original file line numberDiff line numberDiff line change
@@ -1148,3 +1148,6 @@ end
11481148
@test isequal(ComplexF64(cscd(T(-1000, 100000))), ComplexF64(0.0, -0.0))
11491149
end
11501150
end
1151+
1152+
# real(C) with C a Complex Unionall
1153+
@test real(Complex{<:AbstractFloat}) == AbstractFloat

0 commit comments

Comments
 (0)