Skip to content

Unclear error for two doc comments for a declaration #366

@robinheghan

Description

@robinheghan

Reported by @gilramir on Discord.

The new parser's error message for multiple doc-comments on a function could be clearer. I didn't know until right now that there could only be one doc comment on a function (even with the existing compiler), but I see why it should be so.

From the new parser:

--Could not parse this file-------------------------------- src/ViewItems.gren

21|
22| {-| This is doc comment #1 -}
23| {-| This is doc comment #2 -}
    ^
24| viewItems : Array String -> String
25| viewItems items =

Expected keyword 'port'
Expected keyword 'type'
Invalid character in variable name

whereas in the current parser:

-- UNEXPECTED SYMBOL ---------------------------------------- src/ViewItems.gren

I am getting stuck because this line starts with the { symbol:

23| {-| This is doc comment #2 -}
    ^
When a line has no spaces at the beginning, I expect it to be a declaration like
one of these:

    greet : String -> String
    greet name =
      "Hello " ++ name ++ "!"

    type User = Anonymous | LoggedIn String

If this is not supposed to be a declaration, try adding some spaces before it?

Both versions are unclear, actually 🙂

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions