Skip to content

Commit 9ab918e

Browse files
committed
Add integer check to indices via `eltype(inds) <: Integer
1 parent 32afe1c commit 9ab918e

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

src/ranges.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ specified then indices for visiting each index of `x` is returned.
203203
"""
204204
@inline function indices(x)
205205
inds = eachindex(x)
206-
if inds isa AbstractUnitRange#{<:Integer} # prevents inference
206+
if inds isa AbstractUnitRange && eltype(inds) <: Integer
207207
return Base.Slice(OptionallyStaticUnitRange(inds))
208208
else
209209
return inds

src/static.jl

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,9 @@ Static(::Val{N}) where {N} = Static{N}()
1313
Base.Val(::Static{N}) where {N} = Val{N}()
1414
Base.convert(::Type{T}, ::Static{N}) where {T<:Number,N} = convert(T, N)
1515
Base.convert(::Type{Static{N}}, ::Static{N}) where {N} = Static{N}()
16-
# for S ∈ [:Any, :AbstractIrrational]#, :(Complex{<:Real})]
17-
# let S = :Any
18-
let S = :AbstractIrrational
19-
@eval begin
20-
Base.promote_rule(::Type{<:Static}, ::Type{T}) where {T <: $S} = promote_rule(Int, T)
21-
Base.promote_rule(::Type{T}, ::Type{<:Static}) where {T <: $S} = promote_rule(T, Int)
22-
end
23-
end
16+
17+
Base.promote_rule(::Type{<:Static}, ::Type{T}) where {T <: AbstractIrrational} = promote_rule(Int, T)
18+
Base.promote_rule(::Type{T}, ::Type{<:Static}) where {T <: AbstractIrrational} = promote_rule(T, Int)
2419
for (S,T) [(:Complex,:Real), (:Rational, :Integer), (:(Base.TwicePrecision),:Any)]
2520
@eval Base.promote_rule(::Type{$S{T}}, ::Type{<:Static}) where {T <: $T} = promote_rule($S{T}, Int)
2621
end

0 commit comments

Comments
 (0)