Skip to content

Error broadcasting string getproperty (regression) #189

Closed
@lmiq

Description

@lmiq

Seems that this works in version 0.4.4, but is broken in v0.5 (see this thread)

julia> struct A
         s::String
       end

julia> using StructArrays

julia> v = StructArray([A("a"),A("b")])
2-element StructArray(::Vector{String}) with eltype A:
 A("a")
 A("b")

julia> get_s(x) = x.s
get_s (generic function with 1 method)

julia> get_s(v[1])
"a"

julia> get_s.(v)
ERROR: DimensionMismatch("destination axes (1:0,) are not compatible with source axes (Base.OneTo(2),)")
Stacktrace:
 [1] throwdm(axdest::Tuple{UnitRange{Int64}}, axsrc::Tuple{Base.OneTo{Int64}})
   @ Base.Broadcast ./broadcast.jl:1060
 [2] copyto!
   @ ./broadcast.jl:972 [inlined]
 [3] copyto!
   @ ./broadcast.jl:936 [inlined]
 [4] copy
   @ ./broadcast.jl:908 [inlined]
 [5] materialize(bc::Base.Broadcast.Broadcasted{StructArrays.StructArrayStyle{Base.Broadcast.DefaultArrayStyle{1}}, Nothing, typeof(get_s), Tuple{StructVector{A, NamedTuple{(:s,), Tuple{Vector{String}}}, Int64}}})
   @ Base.Broadcast ./broadcast.jl:883
 [6] top-level scope
   @ REPL[7]:1


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