Skip to content

Commit e495251

Browse files
committed
fix type instability
1 parent 65778de commit e495251

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/intervals/intervals.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ end
100100
function interval(a::T, b::S) where {T<:Real, S<:Real}
101101
if !is_valid_interval(a, b)
102102
@warn "Invalid input, empty interval is returned"
103-
return emptyinterval(promote_type(T, S, Float64))
103+
return emptyinterval(promote_type(T, S))
104104
end
105105

106106
return Interval(a, b)
@@ -135,15 +135,15 @@ include("complex.jl")
135135
function ..(a::T, b::S) where {T, S}
136136
if !is_valid_interval(a, b)
137137
@warn "Invalid input, empty interval is returned"
138-
return emptyinterval(promote_type(T, S, Float64))
138+
return emptyinterval(promote_type(T, S))
139139
end
140140
Interval(atomic(Interval{T}, a).lo, atomic(Interval{S}, b).hi)
141141
end
142142

143143
function ..(a::T, b::Irrational{S}) where {T, S}
144144
if !is_valid_interval(a, b)
145145
@warn "Invalid input, empty interval is returned"
146-
return emptyinterval(promote_type(T, Irrational{S}, Float64))
146+
return emptyinterval(promote_type(T, Irrational{S}))
147147
end
148148
R = promote_type(T, Irrational{S})
149149
Interval(atomic(Interval{R}, a).lo, R(b, RoundUp))
@@ -152,7 +152,7 @@ end
152152
function ..(a::Irrational{T}, b::S) where {T, S}
153153
if !is_valid_interval(a, b)
154154
@warn "Invalid input, empty interval is returned"
155-
return emptyinterval(promote_type(Irrational{T}, S, Float64))
155+
return emptyinterval(promote_type(Irrational{T}, S))
156156
end
157157
R = promote_type(Irrational{T}, S)
158158
return Interval(R(a, RoundDown), atomic(Interval{R}, b).hi)

src/intervals/special.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ larger than the upper one."""
99
emptyinterval(::Type{T}) where T<:Real = Interval{T}(Inf, -Inf)
1010
emptyinterval(x::Interval{T}) where T<:Real = emptyinterval(T)
1111
emptyinterval() = emptyinterval(precision(Interval)[1])
12+
emptyinterval(::Type{<:Integer}) = emptyinterval(Float64)
1213
const= emptyinterval(Float64)
1314

1415
isempty(x::Interval) = x.lo == Inf && x.hi == -Inf
@@ -20,6 +21,7 @@ const ∞ = Inf
2021
entireinterval(::Type{T}) where T<:Real = Interval{T}(-Inf, Inf)
2122
entireinterval(x::Interval{T}) where T<:Real = entireinterval(T)
2223
entireinterval() = entireinterval(precision(Interval)[1])
24+
entireinterval(::Type{<:Integer}) = entireinterval(Float64)
2325

2426
isentire(x::Interval) = x.lo == -Inf && x.hi == Inf
2527
isinf(x::Interval) = isentire(x)

0 commit comments

Comments
 (0)