Skip to content

The new gren-based parser cannot handle block comments in some places #23

Closed

Description

@gilramir

As part of "gren format" testing, I created code with comments all over the place.
Some placements of block comments cannot be parsed by the new parser.

I have placed the comprehensive source file in this repo:
https://github.com/gilramir/gren-bug-reports
under 2026-05-21-comment-placement

You can view the file here: https://github.com/gilramir/gren-bug-reports/blob/main/2026-05-21-comment-placement/src/Broken.gren

Activity

  1. gilramir commented on May 24, 2026

    @gilramir
    ContributorAuthor

    I have updated my gren-bug-reports repo; I had 6 cases, but now 4 are passing and only 2 are failing.
    Specifically, Case1.gren fails to parse:
    https://github.com/gilramir/gren-bug-reports/blob/main/2026-05-21-comment-placement/src/Case1.gren

    % ~/prj/gren-format/gren.sh format --pre-ast Case1.gren
    -- FAILED TO PARSE -------------------------------------------------- Case1.gren
    
    17| 
    18| 
    19| type alias RejectedTypeVarsAlias k {- c -} v =
        ^
    20|     Array { key : k, value : v }
    21| 
    
    Expected character '('
    Expected character '['
    Expected character '_'
    Expected character '{'
    Expected keyword '='
    Expected quote
    Invalid character in variable name
    Not a valid number
    17| 
    18| 
    19| type alias RejectedTypeVarsAlias k {- c -} v =
            ^
    20|     Array { key : k, value : v }
    21| 
    
    Reserved word used as variable: 'type'
    

    and case 6:
    https://github.com/gilramir/gren-bug-reports/blob/main/2026-05-21-comment-placement/src/Case6.gren

    % ~/prj/gren-format/gren.sh format --pre-ast Case6.gren
    -- FAILED TO PARSE -------------------------------------------------- Case6.gren
    
    21| rejectedNegWithGap : Int -> Int
    22| rejectedNegWithGap x =
    23|     - {- between unary minus and operand -} x
             ^
    24| 
    
    Expected character '('
    Expected character '.'
    Expected character '['
    Expected character '\'
    Expected character '_'
    Expected character '{'
    Expected quote
    Invalid character in variable name
    Not a valid number
    
  2. robinheghan commented on May 25, 2026

    @robinheghan
    Member

    Thank you for keeping this up to date

  3. robinheghan commented on Oct 16, 2026

    @robinheghan
    Member

    Case 6 still seems to fail, but is Case 1 fixed on main? It seems to compile on my end

  4. robinheghan commented on Oct 16, 2026

    @robinheghan
    Member

    On further inspection, case 6 doesn't seem to be related to the multi-line comment.

    rejectedNegWithGap : Int -> Int
    rejectedNegWithGap x =
        - x
    

    Fails with the same error, and the problem is that operators used as functions need to be wrapped in parenthesis.

    Legal code would be:

    rejectedNegWithGap : Int -> Int
    rejectedNegWithGap x =
        (-) x
    

    Since I cannot reproduce case 1, and case 6 seems to be invalid syntax, I'm closing this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions