@@ -449,7 +449,7 @@ struct StructArrayStyle{S, N} <: AbstractArrayStyle{N} end
449449
450450# Here we define the dimension tracking behavior of StructArrayStyle
451451function StructArrayStyle {S, M} (:: Val{N} ) where {S, M, N}
452- T = S <: AbstractArrayStyle{M} ? typeof (S (Val (N ))) : S
452+ T = S <: AbstractArrayStyle{M} ? typeof (S (Val {N} ( ))) : S
453453 return StructArrayStyle {T, N} ()
454454end
455455
@@ -463,8 +463,10 @@ Base.@pure cst(::Type{SA}) where {SA} = combine_style_types(array_types(SA).para
463463
464464BroadcastStyle (:: Type{SA} ) where {SA<: StructArray } = StructArrayStyle {typeof(cst(SA)), ndims(SA)} ()
465465
466- Base. similar (bc:: Broadcasted{StructArrayStyle{S, N}} , :: Type{ElType} ) where {S<: DefaultArrayStyle , N, ElType} =
467- isstructtype (ElType) ? similar (StructArray{ElType}, axes (bc)) : similar (Array{ElType}, axes (bc))
466+ function Base. similar (bc:: Broadcasted{StructArrayStyle{S, N}} , :: Type{ElType} ) where {S<: DefaultArrayStyle , N, ElType}
467+ ContainerType = isnonemptystructtype (ElType) ? StructArray{ElType} : Array{ElType}
468+ return similar (ContainerType, axes (bc))
469+ end
468470
469471# for aliasing analysis during broadcast
470472Base. dataids (u:: StructArray ) = mapreduce (Base. dataids, (a, b) -> (a... , b... ), values (components (u)), init= ())
0 commit comments