Skip to content

@doc in @kwdef lead syntax error: duplicate field name #60871

@inkydragon

Description

@inkydragon

MWE

bug.jl

"""
    Bug60871(; x)

kw constructor for `struct Bug60871`
"""
@kwdef struct Bug60871
    x

    @doc """
        Bug60871(x)

    normal constructor with input check
    """
    function Bug60871(x)
        # some checks here
        return new(x)
    end
end

Errors

v1.12.4

julia> include("bug.jl")
Bug60871

julia> methods(Bug60871)
# 2 methods for type constructor:
 [1] Bug60871(; x)
     @ /mnt/j/fork4jl/Kirstine.jl/bug.jl:6
 [2] Bug60871(x)
     @ /mnt/j/fork4jl/Kirstine.jl/bug.jl:14

help?> Bug60871
search: Bug60871

  Bug60871(x)

  normal constructor with input check

  ────────────────────────────────────

  Bug60871(; x)

  kw constructor for struct Bug60871

julia> 

1.13 / nightly

julia> include("bug.jl")
ERROR: LoadError: syntax: duplicate field name: "#1#val" is not unique around util.jl:633
Stacktrace:
 [1] top-level scope
   @ /mnt/j/fork4jl/Kirstine.jl/bug.jl:1
 [2] include(mapexpr::Function, mod::Module, _path::String)
   @ Base ./Base.jl:310
 [3] top-level scope
   @ REPL[1]:1
in expression starting at /mnt/j/fork4jl/Kirstine.jl/bug.jl:1

julia> methods(Bug60871)
ERROR: UndefVarError: `Bug60871` not defined in `Main`

xref:

Metadata

Metadata

Assignees

No one assigned

    Labels

    error messagesBetter, more actionable error messagesmacros@macrosregression 1.13Regression in the 1.13 release

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions