Cannot implement a protocol_ex from another hex project
jjl opened this issue · 7 comments
This effectively means I have to provide all implementions of a protocol in the project that defines it.
Hmm, it should be capable of it, the main project just needs to add in the compiler but that 'should' be it... It compiles by scanning the compiled beam files so it shouldn't matter where the beam file come from since they all end up in the same place...
Can you make a minimal reproduceable project? This is odd... ^.^;
Literally the simplest two project repo i could have come up with demonstrates it https://github.com/jjl/expro
Additional datapoint: i do not get a message about a missing method when partially implementing a protocolex, just the "not implemented"
Additional datapoint: i do not get a message about a missing method when partially implementing a protocolex, just the "not implemented"
Hmm, I'll look at it now
So it looks like two depends on one, however one itself is failing tests?
─➤ mix test 1 ↵
1) test greets the world (OneTest)
test/one_test.exs:5
** (UndefinedFunctionError) function One.hello/0 is undefined or private
code: assert One.hello() == :world
stacktrace:
(one) One.hello()
test/one_test.exs:6: (test)
Finished in 0.03 seconds
1 test, 1 failure
Randomized with seed 501894I'm guessing that is just leftover though. ^.^
As for two, it looks like it's saying that because consolidation is false... o.O
I'm guessing something in how the ebin's are detected, checking... It found the protocol itself but not the implementation, checking... Ahh right! Implementations need to be defined in the same project as the protocol itself, should be easily fixable by combining all found beams 'before' starting consolidation, will require a slight refactoring, hold on... :-)
As an aside (I should document this part) if you pass --verbose to mix compile like mix compile --verbose then both Elixir's Protocol's and protocol_ex's will detail what they are consolidating. :-)
EDIT: Oh right, I'm not passing the option through-out it all, will fix this too.
And now:
╰─➤ rm -r _build; mix compile --verbose
==> protocol_ex
Compiling 2 files (.ex)
Generated protocol_ex app
==> one
Compiling 1 file (.ex)
Generated one app
==> two
Compiling 1 file (.ex)
warning: variable "self" is unused
lib/two.ex:6
Compiled lib/two.ex
Generated two app
Consolidating ProtocolEx's project-wide...
ProtocolEx beam module Elixir.One.PointFive.beam with implementations [One.PointFive.PointFiveTwo]
Consolidating ProtocolEx's project-wide complete.
Consolidated List.Chars
Consolidated Collectable
Consolidated String.Chars
Consolidated Enumerable
Consolidated IEx.Info
Consolidated Inspect
╰─➤ mix test
==> protocol_ex
Compiling 2 files (.ex)
Generated protocol_ex app
==> one
Compiling 1 file (.ex)
Generated one app
==> two
Compiling 1 file (.ex)
warning: variable "self" is unused
lib/two.ex:6
Generated two app
.
Finished in 0.02 seconds
1 test, 0 failures
Randomized with seed 837724And fixed, publishing a new version, complete as 0.3.23. :-)
Thanks much!