Skip to content

Commit

Permalink
Update complex docstring with Missing (JuliaLang#52052)
Browse files Browse the repository at this point in the history
The docstring of `complex(T::Type)` is a bit incorrect if `T` contains
`Missing`.

```julia
julia> T = Union{Int, Missing}
Union{Missing, Int64}

julia> complex(T)
Union{Missing, Complex{Int64}}

julia> typeof(complex(zero(T)))
Complex{Int64}
```
  • Loading branch information
hyrodium authored Nov 7, 2023
1 parent 494da96 commit e7345b8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion base/complex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ complex(x::Real, y::Real) = Complex(x, y)
complex(T::Type)
Return an appropriate type which can represent a value of type `T` as a complex number.
Equivalent to `typeof(complex(zero(T)))`.
Equivalent to `typeof(complex(zero(T)))` if `T` does not contain `Missing`.
# Examples
```jldoctest
Expand All @@ -187,6 +187,9 @@ Complex{Int64}
julia> complex(Int)
Complex{Int64}
julia> complex(Union{Int, Missing})
Union{Missing, Complex{Int64}}
```
"""
complex(::Type{T}) where {T<:Real} = Complex{T}
Expand Down

0 comments on commit e7345b8

Please sign in to comment.