OvermindDL1 / protocol_ex

Elixir Extended Protocol
https://hex.pm/packages/protocol_ex
48 stars 5 forks source link

Does not warn when trashing a module that already exists #23

Open jjl opened 6 years ago

jjl commented 6 years ago

I was just doing some heavy refactoring and forgot to remove a protocol_ex that shared a name with a new module. It took me a little while to figure out protocol_ex was overwriting my module silently. It would have been lovely to get a message something like this:

[protocol_ex] warn: overwriting existing module {NAME}

In this case, it was the name of a protocol_ex, but it makes sense to do the same for names of defimpls

OvermindDL1 commented 6 years ago

Hmm, it's hard to do that though as it creates and rebinds itself a few times as it builds up the protocol, especially when re-compiling over itself, so if I add that then it would warn on every recompile for example... As for defimpl_ex's, they should already work fine, a quick test shows:

warning: redefining module Bloop.Integer (current version defined in memory)

So that is good. Any ideas on how to handle protocol_ex's themselves considering they rewrite themselves a few times to build up to allow recursive-referencing implementations?

OvermindDL1 commented 6 years ago

I get warning: redefining module Blah (current version defined in memory) when trying to compile a protocol and module with the same name as well.

And I get warning: redefining module :"Elixir.Blah.$ProtocolEx_description$" (current version defined in memory) with duplicate protocol's as well, it looks like it warns in every case?

Do you have a specific example where it does not warn?