AdRoll / rebar3_format

Erlang Formatter for Rebar3
https://tech.nextroll.com/blog/dev/2020/02/25/erlang-rebar3-format.html
MIT License
109 stars 21 forks source link

Error parsing files: undef #315

Closed Kartstig closed 2 years ago

Kartstig commented 2 years ago

Describe the bug Error parsing files: undef

To Reproduce rebar3 format

Expected behavior Formats the code | Produces Error Text

Rebar3 Log

herman@carnage ⏎  DEBUG=1 rebar3 format
===> Load global config file /home/herman/.config/rebar3/rebar.config
===> Compile (apps)
===> Compile (apps)
===> Compile (apps)
===> Not adding provider default auto from module rebar3_auto because it already exists from module rebar3_auto
===> 25.0.2 satisfies the requirement for minimum OTP version 23
===> 25.0.2 satisfies the requirement for minimum OTP version 23
===> Compile (apps)
===> Evaluating config script "/home/herman/spinflip/flux/_build/default/plugins/jiffy/rebar.config.script"
===> Compile (apps)
===> Compile (apps)
===> Expanded command sequence to be run: [app_discovery,format]
===> Running provider: app_discovery
===> Found top-level apps: [flux]
        using config: [{src_dirs,["src"]},{lib_dirs,["apps/*","lib/*","."]}]
===> Evaluating config script "/home/herman/spinflip/flux/_build/default/lib/jiffy/rebar.config.script"
===> Evaluating config script "/home/herman/spinflip/flux/_build/default/lib/jwt/rebar.config.script"
===> Compile (apps)
===> Not adding provider default auto from module rebar3_auto because it already exists from module rebar3_auto
===> 25.0.2 satisfies the requirement for minimum OTP version 23
===> 25.0.2 satisfies the requirement for minimum OTP version 23
===> Compile (apps)
===> Not adding provider default format from module rebar3_format_prv because it already exists from module rebar3_format_prv
===> Evaluating config script "/home/herman/spinflip/flux/_build/default/plugins/jiffy/rebar.config.script"
===> Compile (apps)
===> Not adding provider codecov analyze from module rebar3_codecov_prv because it already exists from module rebar3_codecov_prv
===> Running provider: format
===> Formatter options: #{action => format,output_dir => current}
===> Found 6 files: ["src/car.erl","src/config.erl",
                            "src/fleet_sup.erl","src/flux_app.erl",
                            "src/flux_sup.erl","src/uuid.erl"]
===> Formatting "src/car.erl" with #{module => otp_formatter,
                                            opts =>
                                                #{action => format,
                                                  output_dir => current},
                                            state => nostate}
===> Error parsing files: undef
Stack: [{ktn_dodger,parse_file,
                    ["src/car.erl",
                     [{scan_opts,[text]},
                      no_fail,compact_strings,parse_macro_definitions]],
                    []},
        {rebar3_ast_formatter,format,3,
                              [{file,"/home/herman/spinflip/flux/_build/default/plugins/rebar3_format/src/rebar3_ast_formatter.erl"},
                               {line,17}]},
        {rebar3_format_prv,'-format_files/2-fun-0-',2,
                           [{file,"/home/herman/spinflip/flux/_build/default/plugins/rebar3_format/src/rebar3_format_prv.erl"},
                            {line,148}]},
        {lists,'-filter/2-lc$^0/1-0-',2,[{file,"lists.erl"},{line,1383}]},
        {rebar3_format_prv,format_files,2,
                           [{file,"/home/herman/spinflip/flux/_build/default/plugins/rebar3_format/src/rebar3_format_prv.erl"},
                            {line,146}]},
        {rebar3_format_prv,do,1,
                           [{file,"/home/herman/spinflip/flux/_build/default/plugins/rebar3_format/src/rebar3_format_prv.erl"},
                            {line,52}]},
        {rebar_core,do,2,
                    [{file,"/home/herman/dev/rebar3/src/rebar_core.erl"},
                     {line,155}]},
        {rebar3,run_aux,2,
                [{file,"/home/herman/dev/rebar3/src/rebar3.erl"},{line,193}]}]
===> Unknown Formatting Error: undef

Additional context

--- Local plugins --- rebar3_auto (0.3.3) rebar3_format (1.2.1) rebar3_codecov (0.3.0)



I tried different files with the same error
elbrujohalcon commented 2 years ago

Have you checked #324 ? Are you enabling the new erlang features, particularly maybr_expr?

Kartstig commented 2 years ago

Have you checked #324 ?

? I don't see Issue 324

Are you enabling the new erlang features, particularly maybr_expr?

Not that I'm aware of

elbrujohalcon commented 2 years ago

Have you checked #324 ?

? I don't see Issue 324

Sorry, I meant #314

Kartstig commented 2 years ago

@elbrujohalcon This (below) solved my issue. From https://github.com/AdRoll/rebar3_format/issues/314 Thank you!

ERL_FLAGS="-enable-feature all"