Syntax error on maybe_expr
Alberdi opened this issue · 6 comments
I have the following module:
-module(erlfmt_maybe_app).
-feature(maybe_expr, enable).
-behaviour(application).
-export([start/2, stop/1]).
start(_StartType, _StartArgs) ->
maybe erlfmt_maybe_sup:start_link() end.
stop(_State) ->
ok.
That compiles as expected with erlc
while using Erlang/OTP 26.0.
But running rebar3 fmt
gives the following output and the file is not formatted:
ᐅ DEBUG=1 rebar3 fmt
===> 26.0 satisfies the requirement for minimum OTP version 21
===> Compile (apps)
===> Expanded command sequence to be run: [fmt]
===> Running provider: fmt
src/erlfmt_maybe_app.erl:7:7: syntax error before: erlfmt_maybe_sup
Steps to reproduce:
ᐅ rebar3 new app erlfmt_maybe
ᐅ cd erlfmt_maybe
ᐅ echo "{project_plugins, [erlfmt]}." >> rebar.config
ᐅ echo "{erlfmt, [write]}." >> rebar.config
ᐅ vi src/erlfmt_maybe_app.erl # Edit the file to match the example above
ᐅ DEBUG=1 rebar3 fmt
===> 26.0 satisfies the requirement for minimum OTP version 21
===> Compile (apps)
===> Expanded command sequence to be run: [fmt]
===> Running provider: fmt
src/erlfmt_maybe_app.erl:7:7: syntax error before: erlfmt_maybe_sup
ᐅ rebar3 --version
rebar 3.22.0 on Erlang/OTP 26 Erts 14.0
ᐅ grep version _build/default/plugins/erlfmt/hex_metadata.config
{<<"version">>,<<"1.1.0">>}.
Yes, we don't support maybe
and map comprehensions yet. This needs some work to add this support
I encounter this issue as well. Vote for supporting maybe in this nice tool.
Hello. Is there any plan to support maybe_expr syntax for this tool?
Yes, it is planned, I just didn't have time yet to get to it. But both map comprehensions and maybe are definitely going to be supported.
Cool. Look forward to seeing them in the tool!
This is now supported in 1.3.0 alongside map comprehensions.
erlfmt will behave as if maybe
is always enabled. For older code, it will automatically quote atoms maybe
to 'maybe'
and else
to 'else'
so that the code can work seamlessly regardless, if the feature is enabled or not.