Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generic NamedTuples break fieldtypes #44

Open
tkemmer opened this issue Oct 20, 2022 · 0 comments
Open

Generic NamedTuples break fieldtypes #44

tkemmer opened this issue Oct 20, 2022 · 0 comments

Comments

@tkemmer
Copy link

tkemmer commented Oct 20, 2022

Using named tuples with type variables sometimes leads to errors when the NamedTupleTools package is loaded. In particular, the pirated fieldtypes function causes errors, e.g., when printing the documentation (example code uses Julia 1.8 and NamedTupleTools 0.14.1):

w/o NamedTupleTools (expected behavior)

julia> const Foo{T} = @NamedTuple{a::T}
NamedTuple{(:a,), Tuple{T}} where T

help?> Foo
search: Foo floor pointer_from_objref OverflowError RoundFromZero unsafe_copyto! functionloc StackOverflowError @functionloc OutOfMemoryError UndefKeywordError unsafe_pointer_to_objref

  No documentation found.

  Summary
  ≡≡≡≡≡≡≡≡≡

  struct NamedTuple{(:a,), Tuple{T}}

  Fields
  ≡≡≡≡≡≡≡≡

  a :: T

w/ NamedTupleTools

julia> using NamedTupleTools

julia> const Foo{T} = @NamedTuple{a::T}
NamedTuple{(:a,), Tuple{T}} where T

help?> Foo
search: Foo FooBar floor pointer_from_objref OverflowError RoundFromZero unsafe_copyto! functionloc StackOverflowError @functionloc OutOfMemoryError UndefKeywordError unsafe_pointer_to_objref

ERROR: UndefVarError: T not defined
Stacktrace:
 [1] fieldtypes(#unused#::Type{NamedTuple{(:a,), Tuple{T}}})
   @ NamedTupleTools ~/.julia/packages/NamedTupleTools/2Wwof/src/NamedTupleTools.jl:66
 [2] summarize(io::IOBuffer, TT::Type, binding::Base.Docs.Binding)
   @ REPL /usr/lib64/julia-1.8.2/share/julia/stdlib/v1.8/REPL/src/docview.jl:286
 [3] summarize(binding::Base.Docs.Binding, sig::Type)
   @ REPL /usr/lib64/julia-1.8.2/share/julia/stdlib/v1.8/REPL/src/docview.jl:249
 [4] doc(binding::Base.Docs.Binding, sig::Type)
   @ REPL /usr/lib64/julia-1.8.2/share/julia/stdlib/v1.8/REPL/src/docview.jl:182
 [5] doc(binding::Base.Docs.Binding)
   @ REPL /usr/lib64/julia-1.8.2/share/julia/stdlib/v1.8/REPL/src/docview.jl:160
 [6] top-level scope
   @ /usr/lib64/julia-1.8.2/share/julia/stdlib/v1.8/REPL/src/docview.jl:474

Notably, this breaks otherwise valid Julia code by just using the NamedTupleTools package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant