Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix throw_complex_domainerror error message for log[1p] #28621

Merged
merged 2 commits into from
Aug 15, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions base/math.jl
Original file line number Diff line number Diff line change
Expand Up @@ -198,17 +198,17 @@ julia> log(4,2)
0.5

julia> log(-2, 3)
ERROR: DomainError with log:
-2.0 will only return a complex result if called with a complex argument. Try -2.0(Complex(x)).
ERROR: DomainError with -2.0:
log will only return a complex result if called with a complex argument. Try log(Complex(x)).
Stacktrace:
[1] throw_complex_domainerror(::Float64, ::Symbol) at ./math.jl:31
[1] throw_complex_domainerror(::Symbol, ::Float64) at ./math.jl:31
[...]

julia> log(2, -3)
ERROR: DomainError with log:
-3.0 will only return a complex result if called with a complex argument. Try -3.0(Complex(x)).
ERROR: DomainError with -3.0:
log will only return a complex result if called with a complex argument. Try log(Complex(x)).
Stacktrace:
[1] throw_complex_domainerror(::Float64, ::Symbol) at ./math.jl:31
[1] throw_complex_domainerror(::Symbol, ::Float64) at ./math.jl:31
[...]
```

Expand Down Expand Up @@ -459,10 +459,10 @@ julia> log1p(0)
0.0

julia> log1p(-2)
ERROR: DomainError with log1p:
-2.0 will only return a complex result if called with a complex argument. Try -2.0(Complex(x)).
ERROR: DomainError with -2.0:
log1p will only return a complex result if called with a complex argument. Try log1p(Complex(x)).
Stacktrace:
[1] throw_complex_domainerror(::Float64, ::Symbol) at ./math.jl:31
[1] throw_complex_domainerror(::Symbol, ::Float64) at ./math.jl:31
[...]
```
"""
Expand Down
8 changes: 4 additions & 4 deletions base/special/log.jl
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ function log(x::Float64)
elseif isnan(x)
NaN
else
throw_complex_domainerror(x, :log)
throw_complex_domainerror(:log, x)
end
end

Expand Down Expand Up @@ -318,7 +318,7 @@ function log(x::Float32)
elseif isnan(x)
NaN32
else
throw_complex_domainerror(x, :log)
throw_complex_domainerror(:log, x)
end
end

Expand Down Expand Up @@ -353,7 +353,7 @@ function log1p(x::Float64)
elseif isnan(x)
NaN
else
throw_complex_domainerror(x, :log1p)
throw_complex_domainerror(:log1p, x)
end
end

Expand Down Expand Up @@ -386,7 +386,7 @@ function log1p(x::Float32)
elseif isnan(x)
NaN32
else
throw_complex_domainerror(x, :log1p)
throw_complex_domainerror(:log1p, x)
end
end

Expand Down