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

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

Open
dzhang314 opened this issue Sep 13, 2024 · 0 comments
Open

Comments

@dzhang314
Copy link

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.

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