elm-tooling / tree-sitter-elm

Tree sitter implementation for elm
https://elm-tooling.github.io/tree-sitter-elm/
MIT License
74 stars 12 forks source link

Parser errors around white-space-filled multiline comments #113

Closed jfmengels closed 2 years ago

jfmengels commented 2 years ago

Parsing fails when encountering multiline comments that only contain whitespace and are on multiple lines.

Expected Behavior

Multi-line comments should not cause parser errors, even when empty.

Current Behavior

Possible Solution

Make the comment parser to accept empty but multiline comments?

Steps to Reproduce (for bugs)

Add the following code to a source file

module A exposing (match)

{-
-}

match : String -> Maybe ( String, String )
match input =
    Nothing

I also see this happen while inside function code:

match : String -> Maybe ( String, String )
match input =
    {-
-}
    Nothing

The problem disappears when you add something to the comment, for instance changing it to {-a\n-}, making it a one-liner {- -}, or when the ending -} does not start at the beginning of the line.

Context

Because this causes parsing errors, the source code that comes after it is marked as having errors. Also, a lot of the values (imports, ...) that are declared before the comment but used after the comment are marked as unused, which shows a lot of errors in the VSCode editor's "Problems" summary panel.

Your Environment