Skip to content

Commit fb4928d

Browse files
committed
fix T(x::T) ambiguity (closes #85)
1 parent ad5f8ad commit fb4928d

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/DecFP.jl

+2-1
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,10 @@ for w in (32,64,128)
102102
Ti = Symbol(string("UInt",w))
103103
@eval struct $BID <: DecimalFloatingPoint
104104
x::$Ti
105-
$BID(x) = convert($BID, x)
105+
$BID(x::Number) = convert($BID, x)
106106
Base.reinterpret(::Type{$BID}, x::$Ti) = new(x)
107107
end
108+
# fix method ambiguities:
108109
@eval $BID(x::Rational{T}) where {T} = convert($BID, x)
109110
end
110111

test/runtests.jl

+3
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,9 @@ for T in (Dec32, Dec64, Dec128)
208208

209209
@test typeof(xd * pi) == T
210210
@test typeof((xd+yd*im)*pi) == Complex{T}
211+
212+
# issue #85
213+
@test T(1.5) == T(T(1.5))
211214
end
212215

213216
@test unsafe_load(DecFP.flags[]) == 0

0 commit comments

Comments
 (0)