From 3f204b5839d4ec06f8186f1f27ec5a3d922a2d80 Mon Sep 17 00:00:00 2001 From: Neven Sajko Date: Mon, 21 Oct 2024 21:33:02 +0200 Subject: [PATCH] define `propertynames(::FixedSizeArray)` Make both fields private. --- src/FixedSizeArrays.jl | 8 ++++++++ test/runtests.jl | 11 +++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/FixedSizeArrays.jl b/src/FixedSizeArrays.jl index 6aeac57..0421c82 100644 --- a/src/FixedSizeArrays.jl +++ b/src/FixedSizeArrays.jl @@ -19,6 +19,14 @@ struct FixedSizeArray{T,N,Mem<:GenericMemory{<:Any,T}} <: DenseArray{T,N} end end +function Base.propertynames( + # the `unused` is here because of https://github.com/JuliaLang/julia/issues/44428 + (@nospecialize unused::FixedSizeArray), + ::Bool = false, +) + () +end + const FixedSizeVector{T} = FixedSizeArray{T,1} const FixedSizeMatrix{T} = FixedSizeArray{T,2} diff --git a/test/runtests.jl b/test/runtests.jl index 3483b01..0530668 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -125,6 +125,17 @@ end FSM = fsm(storage_type) FSA = fsa(storage_type) + @testset "`propertynames`" begin + for dim_count ∈ 0:4 + for T ∈ (Int, Float32) + siz = ntuple(Returns(1), dim_count) + arr = FSA{T}(undef, siz) + test_inferred(propertynames, Tuple{}, (arr,)) + test_inferred(propertynames, Tuple{}, (arr, false)) + end + end + end + @testset "Constructors" begin for dim_count ∈ 0:4 siz = ntuple(Returns(2), dim_count)