Skip to content

False positive: Adding new constructors to aliases of parameterized types #394

@dzhang314

Description

@dzhang314

Consider the following Julia code:

module M

struct Container{T}
    value::T
end

const IntContainer = Container{Int}

function IntContainer(x::Float64)
    return IntContainer(round(Int, x))
end

end # module M

This yields blue squiggles under the definition of function IntContainer(x::Float64) with the following message:

Cannot define function ; it already has a value. Julia(CannotDefineFuncAlreadyHasValue)

This pattern occurs a lot in my package MultiFloats.jl, where I have a generic type MultiFloat{T,N}, and then I define aliases const Float64x2 = MultiFloat{Float64,2} with their own constructors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions