error-message-catalog icon indicating copy to clipboard operation
error-message-catalog copied to clipboard

Two multiline comments without code between them trigger a parsing error

Open pdamoc opened this issue 4 years ago • 3 comments

SSCCE

module Error exposing (..)

import Dict


{-| Foo
-}


{-| Foo
-}
x =
    1
  • Elm: 0.19.1
  • Operating System: mac

Additional Details

The actual compiler error starts with I am getting stuck because this line starts with the { symbol:

This was triggered by commenting out a function that had documentation comments above while bellow it there were other functions with documentation comments. The code looked more like this:

{-| Foo
-}
-- addOne : number -> number
-- addOne arg =
--    arg + 1 

{-| Foo
-} 

In the SSCCE, if import Dict is removed, the error goes away.

If both import Dict and x =1 are removed the another parser error is displayed with the parser getting stuck on the last empty line.

pdamoc avatar Feb 18 '21 18:02 pdamoc

Thanks for reporting this! To set expectations:

  • Issues are reviewed in batches, so it can take some time to get a response.
  • Ask questions in a community forum. You will get an answer quicker that way!
  • If you experience something similar, open a new issue. We like duplicates.

Finally, please be patient with the core team. They are trying their best with limited resources.

github-actions[bot] avatar Feb 18 '21 18:02 github-actions[bot]

Hrm, I think that's correct, as a documentation comment always need a target to comment?

The real block comment syntax seems to parse different and doesn't expect a follow up that's targeted.

module Error exposing (..)

import Dict


{- Foo
-}


{-| Foo
-}
x =
    1

razzeee avatar Feb 18 '21 19:02 razzeee

Hrm, I think that's correct, as a documentation comment always need a target to comment?

A documentation comment is just a multiline comment. If all multiline comments must be documentation comments (i.e. must be followed by a declaration) then this information should be in the syntax guide.

In any case, the code in the SSCCE triggers a parsing error while if it were that all multiline comments must be followed by a declaration, it should have been a syntax error with a very different message.

pdamoc avatar Feb 18 '21 20:02 pdamoc