erlang_ls
erlang_ls copied to clipboard
Formatter removes required parentheses from macro definition
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.
hi Roger, thanks for the report
erlang_ls uses rebar3_format's default_formatter under the hood, and it did have this issue (https://github.com/AdRoll/rebar3_format/issues/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 (https://github.com/erlang-ls/erlang_ls/commit/de81d2075aaf54b7da5cd504a18fee35dbb13ba2) 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?
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
I've opened https://github.com/AdRoll/rebar3_format/issues/293.