rebar3_format icon indicating copy to clipboard operation
rebar3_format copied to clipboard

Comment shifted "down" in a weird fashion

Open paulo-ferraz-oliveira opened this issue 3 years ago • 4 comments

The bug: a comment is getting misplaced.

To reproduce use

-type transaction_error() :: no_workers
                           | not_owner | inet:posix(). % from gen_udp:send

and rebar3 format on top of it.

Expected output is potentially

-type transaction_error() :: no_workers | not_owner | inet:posix(). % from gen_udp:send

but surely not (as is happening):

-type transaction_error() :: no_workers | not_owner | inet:posix().

% from gen_udp:send

paulo-ferraz-oliveira avatar Sep 25 '20 01:09 paulo-ferraz-oliveira

Yes. This is a known issue. If you want to see something even funnier, try with multiple comments, like…

-type transaction_error() :: no_workers
                           | not_owner    % this one will pop up wherever
                           | inet:posix(). % from gen_udp:send

We know about it but we can't promise that we'll fix it soon. In the meantime, when we're formatting stuff like this and find this bug, we just move the comments above the type definition manually. As in…

%% Possible errors in a transaction:
%% - no_workers: We failed to find a worker to run it
%% - not_owner: The caller doesn't own the udp port
%% - inet:posix(). coming from gen_udp:send
-type transaction_error() :: no_workers
                           | not_owner
                           | inet:posix().

elbrujohalcon avatar Sep 25 '20 06:09 elbrujohalcon

It's related to #152

elbrujohalcon avatar Sep 25 '20 06:09 elbrujohalcon

If you want to see something even funnier

😄, I don't want funny, I want "serious" 😛.

can't promise that we'll fix it soon

No hurry here, but I didn't want to lose the chance to report it. I'll give your workaround a go, in the meantime. Thanks.

paulo-ferraz-oliveira avatar Sep 25 '20 09:09 paulo-ferraz-oliveira

This can't be solved until erl_syntax:attribute_arguments/2 quit messing around with node positions, i.e. erlang/otp#4529

elbrujohalcon avatar Feb 17 '21 15:02 elbrujohalcon