diff --git a/src/utils.jl b/src/utils.jl index 5f4e9936..04ca24b1 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -33,6 +33,7 @@ end map_params_as_tuple_fallback(f, ::Type{T}) where {T<:Tup} = map(f, fieldtypes(T)) buildfromschema(initializer::F, ::Type{T}) where {F, T} = buildfromschema(initializer, T, staticschema(T)) +buildfromschema(initializer, ::Type, ::Type{NamedTuple{(), Tuple{}}}) = error("Only structs with fields are supported") """ StructArrays.buildfromschema(initializer, T[, S]) diff --git a/test/runtests.jl b/test/runtests.jl index aabf8c90..19d789cd 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -433,6 +433,9 @@ end t = StructVector([(a=1,), (a=missing,)])::StructVector @test isequal(t.a, [1, missing]) @test eltype(t) <: NamedTuple{(:a,)} + + @test_throws Exception StructArray([nothing]) + @test_throws Exception StructArray([1, 2, 3]) end @testset "tuple case" begin