diff --git a/base/range.jl b/base/range.jl index f56de9118174db..c836d94fe3a922 100644 --- a/base/range.jl +++ b/base/range.jl @@ -876,7 +876,7 @@ end issubset(r::OneTo, s::OneTo) = r.stop <= s.stop issubset(r::AbstractUnitRange{<:Integer}, s::AbstractUnitRange{<:Integer}) = - first(r) >= first(s) && last(r) <= last(s) + isempty(r) || first(r) >= first(s) && last(r) <= last(s) ## linear operations on ranges ## diff --git a/test/ranges.jl b/test/ranges.jl index fdcda964734541..988af1c7c29107 100644 --- a/test/ranges.jl +++ b/test/ranges.jl @@ -387,6 +387,11 @@ end @test !issubset(Base.OneTo(10), Base.OneTo(5)) @test issubset(1:3:10, 1:10) @test !issubset(1:10, 1:3:10) + # with empty ranges + @test issubset(2:1, 3:4) #35225 + @test issubset(2:1, 3:2) + @test issubset(Base.OneTo(0), Base.OneTo(3)) + @test issubset(Base.OneTo(0), Base.OneTo(-3)) end @testset "sort/sort!/partialsort" begin @test sort(UnitRange(1,2)) == UnitRange(1,2)