-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments: Rethink formatting of function with spec and comment #94
Comments
The main complexity in this seems to be - what to do in cases where the comment is in the middle in the first place, e.g. -spec get_service_name(client:api()) -> atom().
% sync with name.app.src
get_service_name(_API) -> name. and also what to do in case of multiple clauses -spec get_service_name(client:api()) -> atom().
get_service_name(#{override: Name}) -> Name; % override
get_service_name(_) -> name. % sync with name.app.src For the first one, I don't think we should be changing it, for the second one, I'm really not sure what would be the right approach. |
The second case as an interesting one! It seems like a good argument to choose option 2 as a more general approach (since comments may be related to specific clauses). |
I think comment placement should not be changed significantly by the formatter. The coder usually has something in mind placing them. I think it's wrong moving them to other places. I think 1. is the only right option. |
We have had another report about comments with spec -spec add(A :: integer(), B :: integer()) -> integer().
%% @private
add(A, B) ->
-spec add(A :: integer(), B :: integer()) -> integer().
%% @private
add(A, B) -> """ |
This last case looks like a bug to me and separate from the initial issue raised here |
I agree :) |
I have retested with master version of erlfmt and the bug does not occur any more. |
After doing more analyses on comments, we have decided that adding support for trailing comments is a good idea #219 Doing it will require a lot of work, so no promises on when this will be delivered, but I believe we can consider this issue a duplicate, because if we support trailing comments, then this wouldn't have been an issue. I hope that makes sense. |
Given the following input
It is formatted too
Better options are:
Where number 1 has gotten a vote and number 3 has gotten at least one vote and one settle.
The text was updated successfully, but these errors were encountered: