Skip to content

Commit 1741a70

Browse files
Merge pull request #693 from AayushSabharwal/as/number-methods
fix: fix `NaNMath.pow` ambiguity resolution in `@number_methods`
2 parents 79da1be + 9176e30 commit 1741a70

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/methods.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ function number_methods(T, rhs1, rhs2, options=nothing)
8080

8181
# Fix method ambiguity error on NaNMath >= 1.0.2 and promotion of `Integer`s on NaNMath < 1.0.2
8282
if f === NaNMath.pow
83-
push!(exprs, :((f::$(typeof(f)))(a::$T, b::Integer) = ($assert_like(f, Number, a); $term($(^), a, b))))
83+
push!(exprs, :((f::$(typeof(f)))(a::$T, b::Integer) = a ^ b))
8484
end
8585
end
8686

test/code.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,13 @@ nanmath_st.rewrites[:nanmath] = true
106106

107107
@test toexpr(a^-1) == :($(/)(1, a))
108108
@test toexpr(a^-1, nanmath_st) == :($(/)(1, a))
109-
@test toexpr(NaNMath.pow(a, -1)) == :($(inv)(a))
110-
@test toexpr(NaNMath.pow(a, -1), nanmath_st) == :($(inv)(a))
109+
@test toexpr(NaNMath.pow(a, -1)) == :($(/)(1, a))
110+
@test toexpr(NaNMath.pow(a, -1), nanmath_st) == :($(/)(1, a))
111111

112112
@test toexpr(a^-2) == :($(/)(1, $(^)(a, 2)))
113113
@test toexpr(a^-2, nanmath_st) == :($(/)(1, $(^)(a, 2)))
114-
@test toexpr(NaNMath.pow(a, -2)) == :($(^)($(inv)(a), 2))
115-
@test toexpr(NaNMath.pow(a, -2), nanmath_st) == :($(^)($(inv)(a), 2))
114+
@test toexpr(NaNMath.pow(a, -2)) == :($(/)(1, $(^)(a, 2)))
115+
@test toexpr(NaNMath.pow(a, -2), nanmath_st) == :($(/)(1, $(^)(a, 2)))
116116

117117
f = GlobalRef(NaNMath, :sin)
118118
test_repr(toexpr(LiteralExpr(:(let x=1, y=2

0 commit comments

Comments
 (0)