diff --git a/Project.toml b/Project.toml index 5844f12..da7bca5 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "StaticArraysCore" uuid = "1e83bf80-4336-4d27-bf5d-d5a4f845583c" -version = "1.4.4" +version = "1.4.5" [compat] julia = "1.6" diff --git a/src/StaticArraysCore.jl b/src/StaticArraysCore.jl index 66d3d06..76318b4 100644 --- a/src/StaticArraysCore.jl +++ b/src/StaticArraysCore.jl @@ -56,6 +56,7 @@ tuple_prod(T::Tuple) = prod(T) tuple_minimum(T::Tuple) = minimum(T) tuple_svec(::Type{T}) where {T<:Tuple} = T.parameters +tuple_svec(::Type{Union{}}) = throw(ArgumentError("Union{} is not a tuple type")) # Julia `Base` provides a function for this purpose since v1.1: `fieldtypes`. # We don't use it yet, though, because it wrecks type inference with Julia diff --git a/test/runtests.jl b/test/runtests.jl index 0a753e8..44c0301 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -22,6 +22,12 @@ using StaticArraysCore, Test @test StaticArraysCore.tuple_length((5, 3)) == 2 @test StaticArraysCore.tuple_prod((5, 3)) == 15 @test StaticArraysCore.tuple_minimum((5, 3)) == 3 + @test Tuple(StaticArraysCore.tuple_svec(Tuple{})) === () + @test Tuple(StaticArraysCore.tuple_svec(Tuple{5,3})) === (5, 3) + @test Tuple(StaticArraysCore.tuple_svec(Tuple{Int,Float64})) === (Int, Float64) + @test_throws ArgumentError StaticArraysCore.tuple_svec(Union{}) + @test_throws ArgumentError StaticArraysCore.tuple_tuple(Union{}) + @test_throws ArgumentError StaticArraysCore.size_to_tuple(Union{}) @test StaticArraysCore.StaticArrayStyle{1}(Val(2)) === StaticArraysCore.StaticArrayStyle{2}() end