Skip to content

Commit

Permalink
throw if no fields
Browse files Browse the repository at this point in the history
  • Loading branch information
aplavin committed Jun 28, 2022
1 parent 3fe67c7 commit e25d809
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
3 changes: 3 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e25d809

Please sign in to comment.