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

Formatter removes required parentheses from macro definition #1168

Open
rlipscombe opened this issue Jan 6, 2022 · 3 comments
Open

Formatter removes required parentheses from macro definition #1168

rlipscombe opened this issue Jan 6, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@rlipscombe
Copy link

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.

@rlipscombe rlipscombe added the bug Something isn't working label Jan 6, 2022
@gomoripeti
Copy link
Contributor

hi Roger, thanks for the report

erlang_ls uses rebar3_format's default_formatter under the hood, and it did have this issue (AdRoll/rebar3_format#74) but it seems to be fixed since version 0.8.0. rebar3_format 0.8.2 is used since erlang_ls 0.10.0 (de81d20) I assume you use a newer version.

Do you use rebar3_format as a plugin of you project or only as part of erlang_ls?
if you have time, could you double check if this issue occurs also with the latest version of rebar3_format?

@rlipscombe
Copy link
Author

rlipscombe commented Jan 7, 2022

I assume you use a newer version.

$ code --list-extensions --show-versions | grep erlang-ls
[email protected]
$ ~/.vscode/extensions/erlang-ls.erlang-ls-0.0.32/erlang_ls/_build/default/bin/erlang_ls --version
Version: 0.21.2

Do you use rebar3_format as a plugin of you project or only as part of erlang_ls?

Only as part of erlang_ls. I'll add it as a plugin.

if you have time, could you double check if this issue occurs also with the latest version of rebar3_format?

Still occurs with v1.0.1:

$ rebar3 format
===> Fetching rebar3_format v1.0.1

@rlipscombe
Copy link
Author

I've opened AdRoll/rebar3_format#293.

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