Skip to content

Accessing the field docstring of a parametric struct gives MethodError in the REPL #59524

@francis-biocurie

Description

@francis-biocurie

Hi,

On julia 1.11.6 we can document the fields of a struct, as described in here in the Julia documentation.

If I define:

"MyStruct type docstring"
struct MyStruct
    "x docstring"
    x::Float64
end

I get in the REPL help-mode (as expected):

help?> MyStruct
search: MyStruct struct abstract

  MyStruct type docstring

help?> MyStruct.x
  x docstring

But, If I define a parametric struct:

"MyParamStruct type docstring"
struct MyParamStruct{T<:Real}
    "x docstring"
    x::T
end

I get:

help?> MyParamStruct
search: MyParamStruct MyStruct

  MyParamStruct type docstring

help?> MyParamStruct.x
ERROR: MethodError: no method matching Base.Docs.Binding(::Type{MyParamStruct}, ::Symbol)
The type `Base.Docs.Binding` exists, but no method is defined for this combination of argument types when trying to construct it.

Closest candidates are:
  Base.Docs.Binding(::Module, ::Symbol)
   @ Base docs/bindings.jl:9

Stacktrace:
 [1] (::REPL.Logged{DataType})(::Type, ::Vararg{Any})
   @ REPL ~/.julia/juliaup/julia-1.11.6+0.x64.linux.gnu/share/julia/stdlib/v1.11/REPL/src/docview.jl:174
 [2] top-level scope
   @ ~/.julia/juliaup/julia-1.11.6+0.x64.linux.gnu/share/julia/stdlib/v1.11/REPL/src/docview.jl:632

The help-mode of the REPL should also work for the fields of a parametric struct.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    REPLJulia's REPL (Read Eval Print Loop)bugIndicates an unexpected problem or unintended behaviordocsystemThe documentation building system

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions