Open onno-vos-dev opened 1 year ago
Describe the bug Trying to format a binary comprehension such as:
<< (integer_to_binary(I)) || <<I>> <= <<"12345">> >>.
results in formatted code such as AFTER having produced an error for it:
<< integer_to_binary(I) || <<I>> <= <<"12345">> >>.
which is both incorrect and doesn't compile due to:
===> Compiling src/binary_comprehension_bad_format.erl failed src/binary_comprehension_bad_format.erl:6:23: syntax error before: '(' src/binary_comprehension_bad_format.erl:3:2: function bad_format/0 undefined
To Reproduce
-module(binary_comprehension_bad_format). -export([bad_format/0]). bad_format() -> << (integer_to_binary(I)) || <<I>> <= <<"12345">> >>.
Steps to reproduce the behavior.
Expected behavior Binary comprehensions can be formatted correctly
Rebar3 Log
===> Formatting "src/binary_comprehension_bad_format.erl" with #{module => default_formatter, opts => #{action => format, break_indent => 2, output_dir => current, paper => 100, parse_macro_definitions => true, ribbon => 100, truncate_strings => true}, state => nostate} ===> Error parsing files: {modified_ast, "src/binary_comprehension_bad_format.erl", "src/binary_comprehension_bad_format.erl"} Stack: [{rebar3_ast_formatter,format,3, [{file,"/home/onnovos/src/github/aws-beam/aws-erlang/_build/default/plugins/rebar3_format/src/rebar3_ast_formatter.erl"}, {line,40}]}, {rebar3_format_prv,'-format_files/2-fun-0-',2, [{file,"/home/onnovos/src/github/aws-beam/aws-erlang/_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/onnovos/src/github/aws-beam/aws-erlang/_build/default/plugins/rebar3_format/src/rebar3_format_prv.erl"}, {line,146}]}, {rebar3_format_prv,do,1, [{file,"/home/onnovos/src/github/aws-beam/aws-erlang/_build/default/plugins/rebar3_format/src/rebar3_format_prv.erl"}, {line,52}]}, {rebar_core,do,2, [{file,"/home/runner/work/rebar3/rebar3/apps/rebar/src/rebar_core.erl"}, {line,155}]}, {rebar3,run_aux,2, [{file,"/home/runner/work/rebar3/rebar3/apps/rebar/src/rebar3.erl"}, {line,193}]}, {rebar3,main,1, [{file,"/home/runner/work/rebar3/rebar3/apps/rebar/src/rebar3.erl"}, {line,66}]}] =ERROR REPORT==== 17-Mar-2023::19:54:21.602021 === added: [{tree,no, {attr,no,[],none}, "bad_format( ) -> << integer_to_binary( I ) || << I >> <= << \"12345\" >> >> .\n"}] modified_ast: src/binary_comprehension_bad_format.erl removed: [{function,no,bad_format,0, [{clause,no,[],[], [{bc,no, {call,no,{atom,no,integer_to_binary},[{var,no,'I'}]}, [{b_generate,no, {bin,no,[{bin_element,no,{var,no,'I'},default,default}]}, {bin,no, [{bin_element,no, {string,no,"12345"}, default,default}]}}]}]}]}] ===> Unknown Formatting Error: {modified_ast, "src/binary_comprehension_bad_format.erl", "src/binary_comprehension_bad_format.erl"}
Describe the bug Trying to format a binary comprehension such as:
results in formatted code such as AFTER having produced an error for it:
which is both incorrect and doesn't compile due to:
To Reproduce
Steps to reproduce the behavior.
Expected behavior Binary comprehensions can be formatted correctly
Rebar3 Log