gren-lang / gren-lang/compiler-common
new parser fails to parse a constructor-application pattern aliased with "as"
Nobody has claimed this yet.
- 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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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