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

Method overwritten warnings, take 2 #7

Open
mauro3 opened this issue Aug 2, 2016 · 6 comments
Open

Method overwritten warnings, take 2 #7

mauro3 opened this issue Aug 2, 2016 · 6 comments

Comments

@mauro3
Copy link
Owner

mauro3 commented Aug 2, 2016

PR #5 fixed most of the method overwritten warnings, but not all:

julia> @traitfn g{X; Tr{X}}(x::X) = 1
g (generic function with 2 methods)

julia> @traitfn g{X; !Tr{X}}(::X) = 2
WARNING: Method definition g(#X<:Any) in module Main at /home/mauro/.julia/v0.5/SimpleTraits/src/SimpleTraits.jl:160 overwritten at /home/mauro/.julia/v0.5/SimpleTraits/src/SimpleTraits.jl:160.
g (generic function with 3 methods)

julia> g(5)
1

julia> g(5.0)
2

If this becomes fixable at some stage without too much effort/code, then fix.

@mauro3
Copy link
Owner Author

mauro3 commented Oct 13, 2016

With the traitor syntax this will be hit more often as the type often gets gensym'ed:

julia> @traitfn f(a::::Tr) = a
f (generic function with 2 methods)

julia> @traitfn f(a::::(!Tr)) = -a
WARNING: Method definition f(###272<:Any) in module Main at /home/mauro/.julia/v0.5/SimpleTraits/src/SimpleTraits.jl:239 overwritten at /home/mauro/.julia/v0.5/SimpleTraits/src/SimpleTraits.jl:239.
f (generic function with 3 methods)

Edit: this is now fixed but above still not.

@juliohm
Copy link

juliohm commented Feb 27, 2021

We are hitting this issue in Meshes.jl, any idea on how to solve it in Julia v1.5 and beyond?

@juliohm
Copy link

juliohm commented Mar 2, 2021

@mauro3 is there another way to express the same thing that would avoid the warning? I was assuming that this was a quite common pattern.

@timholy
Copy link
Collaborator

timholy commented Mar 2, 2021

The way to fix this is to clearly separate the "trait depot" function from the dispatched handlers. Create the depot only once. That means folks have to agree on the traits they want.

@juliohm
Copy link

juliohm commented Mar 2, 2021

I am not sure I understand the comment @timholy can you clarify with an example? This is the code that is producing the warning in our case: https://github.com/JuliaGeometry/Meshes.jl/blob/11e2ba938b2bfb6cb4e3d74bddab2752917e8f54/src/viewing.jl#L62-L64

We agreed on the IsGrid as a temporary trait while we refine the traits in the package. It indicates domains that behave like a CartesianGrid, Image, etc. How to modify that code to avoid the warning?

@juliohm
Copy link

juliohm commented Apr 5, 2021

The solution consisted of giving the argument the same name: JuliaGeometry/Meshes.jl#110

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

3 participants