Skip to content

Commit

Permalink
Fix #30944, ranges with non-IEEEFloat types (#30952)
Browse files Browse the repository at this point in the history
  • Loading branch information
daanhb authored and mbauman committed Jul 5, 2019
1 parent cd79fe6 commit b2ac7a3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions base/range.jl
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ _range(a::Real, st::AbstractFloat, ::Nothing, len::Integer) = _range(fl
_range(a::AbstractFloat, st::Real, ::Nothing, len::Integer) = _range(a, float(st), nothing, len)
_range(a, ::Nothing, ::Nothing, len::Integer) = _range(a, oftype(a-a, 1), nothing, len)

_range(a::T, step::T, ::Nothing, len::Integer) where {T <: AbstractFloat} =
_rangestyle(OrderStyle(T), ArithmeticStyle(T), a, step, len)
_range(a::T, step, ::Nothing, len::Integer) where {T} =
_rangestyle(OrderStyle(T), ArithmeticStyle(T), a, step, len)
_rangestyle(::Ordered, ::ArithmeticWraps, a::T, step::S, len::Integer) where {T,S} =
Expand Down
7 changes: 7 additions & 0 deletions test/ranges.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1512,3 +1512,10 @@ end
Base.TwicePrecision(-1.0, -0.0), 0)
@test reverse(reverse(1.0:0.0)) === 1.0:0.0
end

@testset "Issue #30944 ranges with non-IEEEFloat types" begin
# We want to test the creation of a range with BigFloat start or step
@test range(big(1.0), length=10) == big(1.0):1:10
@test range(1, step = big(1.0), length=10) == big(1.0):1:10
@test range(1.0, step = big(1.0), length=10) == big(1.0):1:10
end

0 comments on commit b2ac7a3

Please sign in to comment.