Skip to content
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

Removes too many parentheses in macro definition #293

Open
rlipscombe opened this issue Jan 7, 2022 · 1 comment
Open

Removes too many parentheses in macro definition #293

rlipscombe opened this issue Jan 7, 2022 · 1 comment
Labels
bug Something isn't working
Milestone

Comments

@rlipscombe
Copy link

From erlang-ls/erlang_ls#1168

I've got the following macro:

% note the parens:
-define(METRICS, (application:get_env(?APP, metrics_module, ?DEFAULT_METRICS_MODULE))).
%                ^                                                                  ^

...which I use like this:

notify_cache_hit() -> ?METRICS:increment(cache_hits).

When I run the formatter, it removes the parentheses, giving me this:

% this is wrong:
-define(METRICS, application:get_env(?APP, metrics_module, ?DEFAULT_METRICS_MODULE)).

This is incorrect, and causes syntax error before: ':' errors when I attempt to use the macro.

I've confirmed that this happens with rebar3_format v1.0.1, outside of ErlangLS.

@elbrujohalcon
Copy link
Collaborator

elbrujohalcon commented Jan 7, 2022

Thanks for the report, @rlipscombe … It's likely related to #74 and #216.

Macros with code in them are generally a pain point for the formatter.

:trollface: Also for code maintainers…
but that's none of my business

@elbrujohalcon elbrujohalcon modified the milestones: 1.1.0, 1.1.1 Apr 11, 2022
@elbrujohalcon elbrujohalcon modified the milestones: 1.1.1, 1.1.2 May 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants