Skip to content

new parser fails to parse a constructor-application pattern aliased with "as" #31

Description

@gilramir

When a constructor applied to a "as name" without parens is used, the parser fails to parse it.
Found when parsing core.git's src/String/Parser/Advanced.gren:

 365     Just { first = Parser parse, rest = remainingParsers } ->
 366       when parse s0 is
 367         Good _ as step ->
 368           step

Minimal repro:

module AsPatternRepro exposing (f)


f x =
    when x is
        Just y as whole ->
            whole

        _ ->
            x

when parsed:

 % ./gren-format/gren-format.sh /tmp/ex.gren 
-- FAILED TO PARSE ------------------------------------------------ /tmp/ex.gren

4| f x =
5|     when x is
6|         Just y as whole ->
                  ^
7|             whole
8| 

Expected keyword '->'

But with parens, it parses fine:

module AsPatternRepro exposing (f)


f x =
    when x is
        (Just y) as whole ->
            whole

        _ ->
            x

Surely this is related to #30

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