Skip to content

Commit e679776

Browse files
committed
Detect ambiguities and unbound_args.
1 parent c6c9c9b commit e679776

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/ranges.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ struct OptionallyStaticUnitRange{T <: Integer, F <: Integer, L <: Integer} <: Ab
9090
end
9191
end
9292

93-
Base.:(:)(L, ::Static{U}) where {U} = OptionallyStaticUnitRange(L, Static(U))
94-
Base.:(:)(::Static{L}, U) where {L} = OptionallyStaticUnitRange(Static(L), U)
93+
Base.:(:)(L::Integer, ::Static{U}) where {U} = OptionallyStaticUnitRange(L, Static(U))
94+
Base.:(:)(::Static{L}, U::Integer) where {L} = OptionallyStaticUnitRange(Static(L), U)
9595
Base.:(:)(::Static{L}, ::Static{U}) where {L,U} = OptionallyStaticUnitRange(Static(L), Static(U))
9696

9797
Base.first(r::OptionallyStaticUnitRange) = r.start
@@ -142,6 +142,7 @@ end
142142
end
143143

144144
@inline _try_static(::Static{N}, ::Static{N}) where {N} = Static{N}()
145+
@inline _try_static(::Static{M}, ::Static{N}) where {M, N} = @assert false "Unequal Indices: Static{$M}() != Static{$N}()"
145146
function _try_static(::Static{N}, x) where {N}
146147
@assert N == x "Unequal Indices: Static{$N}() != x == $x"
147148
Static{N}()

test/runtests.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ using Base: setindex
33
import ArrayInterface: has_sparsestruct, findstructralnz, fast_scalar_indexing, lu_instance, Static
44
@test ArrayInterface.ismutable(rand(3))
55

6+
@test isempty(detect_unbound_args(ArrayInterface))
7+
@test isempty(detect_ambiguities(ArrayInterface))
8+
69
using StaticArrays
710
x = @SVector [1,2,3]
811
@test ArrayInterface.ismutable(x) == false
@@ -243,6 +246,7 @@ end
243246
@test_throws AssertionError ArrayInterface.indices((A23, ones(3, 3)), (1, 2))
244247
@test_throws AssertionError ArrayInterface.indices((SA23, ones(3, 3)), Static(1))
245248
@test_throws AssertionError ArrayInterface.indices((SA23, ones(3, 3)), (Static(1), 2))
249+
@test_throws AssertionError ArrayInterface.indices((SA23, SA23), (Static(1), Static(2)))
246250
end
247251

248252
@testset "Static" begin

0 commit comments

Comments
 (0)