From a3a2b7a058e1b5ff1a1d86c78318391b7f49eb0e Mon Sep 17 00:00:00 2001 From: Jim Garrison Date: Wed, 15 Aug 2018 18:02:44 -0400 Subject: [PATCH] Fix throw_complex_domainerror error message for log[1p] (#28621) * Fix throw_complex_domainerror error message for log[1p] This seems pretty clearly unintentional. Relevant history is in d4229beb7e8d2c665fe6bd3fc9624ec2ffa4d096 and d555a9a3874f4c47e16d1fdcbae4866cc0d3917f. * Require `Symbol` as first argument to `throw_complex_domainerror` --- base/math.jl | 20 ++++++++++---------- base/special/log.jl | 8 ++++---- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/base/math.jl b/base/math.jl index 6e758cf7b83e2..2d58744d61b0d 100644 --- a/base/math.jl +++ b/base/math.jl @@ -27,7 +27,7 @@ using Core.Intrinsics: sqrt_llvm using .Base: IEEEFloat -@noinline function throw_complex_domainerror(f, x) +@noinline function throw_complex_domainerror(f::Symbol, x) throw(DomainError(x, string("$f will only return a complex result if called with a ", "complex argument. Try $f(Complex(x))."))) end @@ -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 [...] ``` @@ -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 [...] ``` """ diff --git a/base/special/log.jl b/base/special/log.jl index 7e52c39c2a5d9..4b6429adf7c2d 100644 --- a/base/special/log.jl +++ b/base/special/log.jl @@ -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 @@ -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 @@ -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 @@ -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