Closed
Description
When using NTuple
in a recursive type, there is a failure of TypeVars to apply:
julia> struct A{N}
children::NTuple{N,A{N}}
end
julia> fieldtypes(A{2})
(Tuple{A, A},)
However, this should be Tuple{A{2}, A{2}}
.
Consider NTuple
by itself:
julia> NTuple{2,Array{Float64,2}}
Tuple{Matrix{Float64}, Matrix{Float64}}
You can use this in structs if it is not recursive:
julia> struct A{N}
children::NTuple{N,Array{Float64,N}}
end
julia> fieldtypes(A{2})
(Tuple{Matrix{Float64}, Matrix{Float64}},)
However, if the type is recursive, the typevar fails to apply in the type parameters.
versioninfo()
:
Julia Version 1.10.4
Commit 48d4fd48430 (2024-06-04 10:41 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: macOS (arm64-apple-darwin22.4.0)
CPU: 8 × Apple M1 Pro
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-15.0.7 (ORCJIT, apple-m1)
Threads: 6 default, 0 interactive, 3 GC (on 6 virtual cores)
Another potentially related failure for NTuple
field types is #55076.
While this fails on 1.10.4, this works on 1.6.7.