Confusing behavior of compiler on a phoenix project

I’m seeing some confusing behavior when I compile my Phoenix project. If I run mix clean and then mix compile, I get:

warning: defp _edit_btns.html/1 is private,
    @doc attribute is always discarded for private functions/macros/types

However, this message does not appear if I rerun mix compile. I’m also confused by the @doc aspect: I don’t have any of these in either the referenced template file or its view.

I suspect that Phoenix is bumping into a compiler issue. If so, should this be filed as an Elixir bug?

This is warning, so you can safely ignore it and nothing bad would happen. Elixir shows warning for files as it compiles them. If you rerun compile, everything is already compiled, so it’s a no-op. This is called incremental compilation. The reason it exists is to make compilation faster, when only one file changes.

The way views and templates work, is that templates are compiled into a private function on the view. Phoenix does that just before the view module is compiled. If I had to guess what your problem is, it’s that you have a @doc after all of your function definitions. Could you share the code for your EditView and _edit_butns.html.eex? That would be the simplest way for others to help.

1 Like

I suspected that incremental compilation was part of the picture, but thanks for the clarification.

Could you share the code for your EditView and _edit_butns.html.eex ?

Sure! Here are some links (as of commit 30f2909):

Your PhxHttp.Types injects a lot of @doc that all have no function. So they get attributed to whatever comes next.

Perhaps you want a @typedoc there?


Thanks! Somehow, I had missed (or forgotten) the @typedoc attribute. I just replaced all of the inappropriate @doc entries and the problem appears to have gone away.