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

Removing function if it has a syntax error #279

Open
rustkas opened this issue Aug 27, 2021 · 2 comments
Open

Removing function if it has a syntax error #279

rustkas opened this issue Aug 27, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@rustkas
Copy link

rustkas commented Aug 27, 2021

Describe the bug

When I run rebar3 format for source code that has some syntax error in some function, that function just scapes from source code.

To Reproduce

Make syntax error then run rebar3 format.

Expected behavior

We get a description in a console and damaged source code.

Rebar3 Log

Run rebar3 with DEBUG=1 and paste its output here. (sorry, I can not do that - The code with syntax error is gone)

** 73: unterminated string starting with ",[Result]).\n    " **

Additional context

Bug description for reproducing:

line     Text="abc123, without ending " in the end
line "{ok, MP} = re:compile(Regex)" do not have and "," at the end

Source code:

-module(recipe_14).

-export([]).

%%
%% Tests
%%
-ifdef(TEST).

-include_lib("eunit/include/eunit.hrl").

research_02_01() ->
    %Expected = "12345678910",
    %?debugFmt("~p~n",[Text]),
    Regex = "\\w+\\d+",
    Text="abc123,
	{ok, MP} = re:compile(Regex)
    {match, [Result]} = re:run(Text, MP, [{capture, first, list}]),
    ?debugFmt("~p~n",[Result]).
    %?_assertEqual(Expected, Result).

-endif.

Stacktrace:

H:\books1\regular expression\regex\Regular Expressions Cookbook 2nd\github\code\ch02\basic>rebar3 format
===> Error parsing files: {modified_ast,"lib/recipe_14/src/recipe_14.erl",
                              "lib/recipe_14/src/recipe_14.erl"}
Stack: [{rebar3_ast_formatter,format,3,
                              [{file,"h:/books1/regular expression/regex/Regular Expressions Cookbook 2nd/github/code/ch02/basic/_build/default/plugins/rebar3_format/src/rebar3_ast_formatter.erl"},
                               {line,40}]},
        {rebar3_format_prv,'-format_files/2-fun-0-',2,
                           [{file,"h:/books1/regular expression/regex/Regular Expressions Cookbook 2nd/github/code/ch02/basic/_build/default/plugins/rebar3_format/src/rebar3_format_prv.erl"},
                            {line,125}]},
        {lists,'-filter/2-lc$^0/1-0-',2,[{file,"lists.erl"},{line,1290}]},
        {rebar3_format_prv,format_files,2,
                           [{file,"h:/books1/regular expression/regex/Regular Expressions Cookbook 2nd/github/code/ch02/basic/_build/default/plugins/rebar3_format/src/rebar3_format_prv.erl"},
                            {line,123}]},
        {rebar3_format_prv,do,1,
                           [{file,"h:/books1/regular expression/regex/Regular Expressions Cookbook 2nd/github/code/ch02/basic/_build/default/plugins/rebar3_format/src/rebar3_format_prv.erl"},
                            {line,43}]},
        {rebar_core,do,2,
                    [{file,"/home/runner/work/rebar3/rebar3/src/rebar_core.erl"},
                     {line,155}]},
        {rebar3,run_aux,2,
                [{file,"/home/runner/work/rebar3/rebar3/src/rebar3.erl"},
                 {line,182}]},
        {rebar3,main,1,
                [{file,"/home/runner/work/rebar3/rebar3/src/rebar3.erl"},
                 {line,66}]}]
=ERROR REPORT==== 27-Aug-2021::09:00:37.853000 ===
    modified_ast: lib/recipe_14/src/recipe_14.erl
    removed: [{error,no}]
    added: [{tree,no,
                  {attr,no,[],none},
                  "* * 73 : unterminated string starting with \",[Result]).\\n    \" * *"}]
===> Unknown Formatting Error: {modified_ast,"lib/recipe_14/src/recipe_14.erl",
                              "lib/recipe_14/src/recipe_14.erl"}
@rustkas rustkas added the bug Something isn't working label Aug 27, 2021
@elbrujohalcon
Copy link
Collaborator

I found a minimal example to reproduce the bug…

-module(recipe_15).

-export([x/0]).

x() ->
    "This is an unterminated string,
    some:more(stuff).

This results in the following when formatted…

-module(recipe_15).

-export([x/0]).

** 6: unterminated string starting with "This is an unter" **

It's actually an issue with ktn_dodger. When we try to parse the file with no_fail… it fails anyway.

@elbrujohalcon
Copy link
Collaborator

I opened inaka/katana-code#66 for this.

@elbrujohalcon elbrujohalcon added this to the Eventually 🙄 milestone Aug 30, 2021
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