diff --git a/Project.toml b/Project.toml index 29d085ac..b9245959 100644 --- a/Project.toml +++ b/Project.toml @@ -12,6 +12,7 @@ Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" [compat] Adapt = "1, 2, 3" +Aqua = "0.7" ConstructionBase = "1" DataAPI = "1" GPUArraysCore = "0.1.2" @@ -21,6 +22,7 @@ Tables = "1" julia = "1.6" [extras] +Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" JLArrays = "27aeb0d3-9eb9-45fb-866b-73c2ecf80fcb" OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881" @@ -32,4 +34,4 @@ TypedTables = "9d95f2ec-7b3d-5a63-8d20-e2491e220bb9" WeakRefStrings = "ea10d353-3f73-51f8-a26c-33c1cb351aa5" [targets] -test = ["Test", "JLArrays", "StaticArrays", "OffsetArrays", "PooledArrays", "TypedTables", "WeakRefStrings", "Documenter", "SparseArrays"] +test = ["Aqua", "Test", "JLArrays", "StaticArrays", "OffsetArrays", "PooledArrays", "TypedTables", "WeakRefStrings", "Documenter", "SparseArrays"] diff --git a/src/structarray.jl b/src/structarray.jl index ee361c39..e77e5951 100644 --- a/src/structarray.jl +++ b/src/structarray.jl @@ -289,12 +289,13 @@ for type in ( :(Tuple{Union{Integer, AbstractUnitRange}, Vararg{Union{Integer, AbstractUnitRange}}}), # disambiguation with Base :(Tuple{Union{Integer, Base.OneTo}, Vararg{Union{Integer, Base.OneTo}}}), + :(Tuple{Integer, Vararg{Integer}}), ) @eval function Base.similar(::Type{<:StructArray{T, N, C}}, sz::$(type)) where {T, N, C} return buildfromschema(typ -> similar(typ, sz), T, C) end - @eval function Base.similar(s::StructArray, S::Type, sz::$(type)) + @eval function Base.similar(s::StructArray, S::Type{T}, sz::$(type)) where T return _similar(s, S, sz) end end @@ -469,8 +470,10 @@ for type in ( :(Tuple{Union{Integer, AbstractUnitRange, Colon}, Vararg{Union{Integer, AbstractUnitRange, Colon}}}), # disambiguation with Base :(Tuple{Union{Integer, Base.OneTo}, Vararg{Union{Integer, Base.OneTo}}}), + :(Tuple{Union{Colon, Integer}, Vararg{Union{Colon, Integer}}}), :(Tuple{Vararg{Union{Colon, Integer}}}), :(Tuple{Vararg{Union{Colon, Int}}}), + :(Tuple{Integer, Vararg{Integer}}), :(Tuple{Colon}), ) @eval function Base.reshape(s::StructArray{T}, d::$(type)) where {T} diff --git a/test/Aqua.jl b/test/Aqua.jl new file mode 100644 index 00000000..79995332 --- /dev/null +++ b/test/Aqua.jl @@ -0,0 +1,5 @@ +using Aqua + +@testset "Aqua.jl" begin + Aqua.test_all(StructArrays) +end diff --git a/test/runtests.jl b/test/runtests.jl index 85a3637d..5ef28321 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -16,6 +16,8 @@ if Base.VERSION >= v"1.6" && Int === Int64 doctest(StructArrays) end +include("Aqua.jl") + # Most types should not be viewed as equivalent merely # because they have the same field names. (Exception: # NamedTuples are distinguished only by field names, so they