I’ve written a small library to serialize Ecto results/changesets into a specific shape needed for a project I’m working on.
Here is the GitHub repo: https://github.com/somlor/tyson
Since upgrading to Elixir 1.3 I’m seeing several warnings running my tests:
warning: function Tyson.FederationSerializer.attributes/1 is undefined or private
warning: function Tyson.FederationSerializer.attributes/2 is undefined or private
It appears the culprit are these direct (non-apply) function calls here:
The problem is, if I rewrite them using
apply(__MODULE__, :attributes, [raw_data])
The warnings disappear but another very strange thing happens. My tests pass the first time after save, but then fail consistently afterwards.
Any ideas on what I’m doing wrong? Also feel free to tear apart my code in general, it’s my first Elixir library.
This is killing me.
Trying to fix warnings again today, in a separate branch I’ve consolidated code into one file for simplicity, renamed the
attributes callback to
attributes_filter, for clarity (since there is also a macro named
attributes) and specified these as an
@optional_callbacks. Still no dice.
Thanks for your input!
Interesting, I wasn’t aware of this function. I’m definitely suspecting it’s related to compilation time, considering my tests pass once on compile but then fail after.
Unfortunately I’m not sure
register_attribute will help in this case, since it pertains to Elixir
@attributes whereas this problem is related to a function that just happens to be called
Ah, likely not then. Can you reduce it to a minimal test-case? I’m not able to test at moment but I or another possibly could soon?
I think I figured it out finally! I stopped trying to support multiple arities for
attributes function (now called attributes_filter) and defined a default version along with a