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

Valid julia expression not parsed properly #788

Open
mmesiti opened this issue Dec 5, 2023 · 1 comment
Open

Valid julia expression not parsed properly #788

mmesiti opened this issue Dec 5, 2023 · 1 comment

Comments

@mmesiti
Copy link

mmesiti commented Dec 5, 2023

Tested on 1.43 - The expression

expr = quote
       function a!(b)
           c = (
           +d+
           +e)
           @f g = h
       end
       end

is parsed without errors by Julia, but the text

       function a!(b)
           c = (
           +d+
           +e)
           @f g = h
       end

chokes JuliaFormatter:

julia> text = "
       function a!(b)
           c = (
           +d+
           +e)
           @f g = h
       end
       "
"\nfunction a!(b)\n    c = (\n    +d+\n    +e)\n    @f g = h\nend\n"

julia> format_text(text)
ERROR: Error while PARSING formatted text:

1 
2 function a!(b)
3     c = (d + +e)
4     @fg = h

...

I have tried to trim down the reproduction case to something even smaller, but I have not managed. Interestingly, it seems that the additional + in the firs expression in the function makes the parser fuse the macro with the first symbol in the expression, but only if the first expression is split into multiple lines... what?

Might be related to #770?

@domluna
Copy link
Owner

domluna commented Dec 5, 2023

CSTParser has trouble with this sort of expressions so I'm guessing it's probably due to that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants