diff --git a/src/structarray.jl b/src/structarray.jl index 687af61..24ab0fb 100644 --- a/src/structarray.jl +++ b/src/structarray.jl @@ -442,6 +442,7 @@ end function Base.empty!(s::StructArray) foreachfield(empty!, s) + return s end function Base.sizehint!(s::StructArray, i::Integer) diff --git a/test/runtests.jl b/test/runtests.jl index 00b5ae4..4484283 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -436,7 +436,7 @@ end @testset "empty" begin s = StructVector(a = [1, 2, 3], b = ["a", "b", "c"]) - empty!(s) + @test empty!(s) === s @test isempty(s.a) @test isempty(s.b) end @@ -1381,7 +1381,7 @@ Base.BroadcastStyle(::Broadcast.ArrayStyle{MyArray2}, S::Broadcast.DefaultArrayS @testset "allocation test" begin a = StructArray{ComplexF64}(undef, 1) sa = StructArray{ComplexF64}((SizedVector{1}(a.re), SizedVector{1}(a.re))) - allocated(a) = @allocated a .+ 1 + allocated(a) = @allocated (+).(a, 1) # `@allocated a .+ 1` is broken on 1.12 @test allocated(a) == 2allocated(a.re) @test allocated(sa) == 2allocated(sa.re) allocated2(a) = @allocated a .= complex.(a.im, a.re)