Skip to content

Commit 8e74a68

Browse files
hyrodiumtimholy
andauthored
Add deprecated message for 1..missing (#99)
* deprecated message for 1..missing * add TODO comment for the next breaking release * Update depwarn message Co-authored-by: Tim Holy <[email protected]> Co-authored-by: Tim Holy <[email protected]>
1 parent 49a8bfe commit 8e74a68

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/interval.jl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,14 @@ mathematical notation, the constructed range is `(left, right)`.
2727
const OpenInterval{T} = Interval{:open,:open,T}
2828

2929
Interval{L,R,T}(i::AbstractInterval) where {L,R,T} = Interval{L,R,T}(endpoints(i)...)
30-
Interval{L,R}(left, right) where {L,R} = Interval{L,R,promote_type(typeof(left), typeof(right))}(left,right)
30+
function Interval{L,R}(left, right) where {L,R}
31+
# TODO: Replace the retrun value with `Interval{L,R}(promote(left,right)...)`. (#93)
32+
T = promote_type(typeof(left), typeof(right))
33+
if !isconcretetype(T)
34+
Base.depwarn("`Promotion to a concrete type failed and will error in the next release; consider constructing this interval as `Interval{L,R,$(typejoin(typeof(left),typeof(right)))}(left, right)`.", :Interval)
35+
end
36+
Interval{L,R,T}(left,right)
37+
end
3138
Interval{L,R}(left::T, right::T) where {L,R,T} = Interval{L,R,T}(left, right)
3239
Interval(left, right) = ClosedInterval(left, right)
3340

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,7 @@ struct IncompleteInterval <: AbstractInterval{Int} end
640640
end
641641

642642
@testset "Missing endpoints" begin
643+
# TODO: Remove this testset in the next breaking release (#94)
643644
@test ismissing(2 in 1..missing)
644645
@test_broken ismissing(2 in missing..1) # would be fixed by julialang#31171
645646
end

0 commit comments

Comments
 (0)