Skip to content

Extending a constructor is possible without explicit import or module prefix #25744

Open
@KristofferC

Description

@KristofferC

Not sure if this is intended:

julia> UUID
ERROR: UndefVarError: UUID not defined

julia> using Random: UUID

julia> UUID(x::String) = UUID(rand(UInt128)) # OK?
UUID

julia> UUID("foo")
8c68d00a-33d1-777d-c4a1-0a41759d1581

julia> using Base: getindex

julia> struct Foo end

julia> getindex(::Foo) = print("Hello")
ERROR: error in method definition: function Base.getindex must be explicitly imported to be extended

Metadata

Metadata

Assignees

Labels

bugIndicates an unexpected problem or unintended behaviormodulestypes and dispatchTypes, subtyping and method dispatch

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions