gren-lang / gren-lang/compiler-common

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

Open
#31 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
No language data
Stars
1
Forks
1
PR merge metrics
No merged PRs in 30d

Description

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 https://github.com/gren-lang/compiler-common/issues/30

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the minimal AsPatternRepro example and run it through gren-format/gren-format.sh to reproduce the failure. Compare the parenthesized and unparenthesized forms, then trace the parser path for the constructor application and as alias; done means the unparenthesized pattern parses successfully while preserving the shown behavior.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.