Skip to content

Feature Request: Singleton type support #335

@MasonProtter

Description

@MasonProtter

Currently:

julia> StructArray([nothing, nothing])
ERROR: ArgumentError: only eltypes with fields are supported
Stacktrace:
 [1] (StructVector{Nothing, @NamedTuple{}})(c::@NamedTuple{})
   @ StructArrays ~/.julia/packages/StructArrays/bgm9N/src/structarray.jl:17
 [2] (StructArray{Nothing})(c::@NamedTuple{})
   @ StructArrays ~/.julia/packages/StructArrays/bgm9N/src/structarray.jl:94
 [3] buildfromschema(initializer::StructArrays.var"#28#29"{}, ::Type{…}, ::Type{…})
   @ StructArrays ~/.julia/packages/StructArrays/bgm9N/src/utils.jl:48
 [4] buildfromschema(initializer::StructArrays.var"#28#29"{typeof(StructArrays.alwaysfalse), Vector{Nothing}}, ::Type{Nothing})
   @ StructArrays ~/.julia/packages/StructArrays/bgm9N/src/utils.jl:35
 [5] similar_structarray(v::Vector{Nothing}, ::Type{Nothing}; unwrap::typeof(StructArrays.alwaysfalse))
   @ StructArrays ~/.julia/packages/StructArrays/bgm9N/src/structarray.jl:182
 [6] StructArray(v::Vector{Nothing}; unwrap::typeof(StructArrays.alwaysfalse))
   @ StructArrays ~/.julia/packages/StructArrays/bgm9N/src/structarray.jl:260
 [7] StructArray(v::Vector{Nothing})
   @ StructArrays ~/.julia/packages/StructArrays/bgm9N/src/structarray.jl:259
 [8] top-level scope
   @ REPL[43]:1
Some type information was truncated. Use `show(err)` to see complete types.

This feels like an unnecessary limitation. I have an application where I want to be able to store collections of StructArrays filled with concrete types that may or may not be singleton types. It's inconvenient for me to have to fall back on regular vectors for singleton structs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions