From f2d035c57e71abfcf5b0fdff138d7550249f3d11 Mon Sep 17 00:00:00 2001 From: N5N3 <2642243996@qq.com> Date: Sun, 28 Dec 2025 13:51:16 +0800 Subject: [PATCH 1/2] Ensure that `empty!` returns the input structarray --- src/structarray.jl | 1 + test/runtests.jl | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) 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..2a65c8a 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 From 6e14270eca88db909f6349f1fcd317e2b3e833bb Mon Sep 17 00:00:00 2001 From: N5N3 <2642243996@qq.com> Date: Sun, 28 Dec 2025 14:36:20 +0800 Subject: [PATCH 2/2] fix test on 1.12+ --- test/runtests.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/runtests.jl b/test/runtests.jl index 2a65c8a..4484283 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -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)