Since upgrading to Elixir 1.3 I’m seeing several warnings running my tests:
warning: function Tyson.FederationSerializer.attributes/1 is undefined or private
test/support/serializers/federation_serializer.ex:2
warning: function Tyson.FederationSerializer.attributes/2 is undefined or private
test/support/serializers/federation_serializer.ex:2
...
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.
Note: Unlike Erlang, user defined attributes are not stored in the module by default. The value exists only during compilation time. A developer can configure an attribute to behave closer to Erlang by calling Module.register_attribute/3.
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 attributes.
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 defoverridable.