Skip to content

Excessive parser backtracking in lambda arguments #3262

Description

@natefaubion

http://try.purescript.org/?backend=core&gist=40b83a8631b49dfb1cc7584aaea0fb1d

module Main where

import Prelude

foo = id \a ->
  let
    bar =
      let
        baz =
          { a: 42, -- Extra comma
          , b: 12
          }
      in baz
  in bar
  Unable to parse module:
  unexpected ->
  expecting indentation at column 1 or end of input

If you remove id then there is a sensible error position.

Activity

  1. paf31 commented on Mar 1, 2018

    @paf31
    Contributor

    A smaller example:

    foo = id \a -> [1,,2]
    
  2. natefaubion commented on Mar 1, 2018

    @natefaubion
    ContributorAuthor

    \ is a valid operator, so maybe since the lambda body parse failed, it's backtracking to parse id \ a. I think since the lambda head is correct, it should be able to commit, since -> is not a valid operator.

  3. natefaubion commented on Aug 8, 2018

    @natefaubion
    ContributorAuthor

    I think this is anything that causes backtracking to Parsec.buildExpressionParser.

    bad = id [,]
    Unable to parse module:
    unexpected [
    

    This example should clearly fail with an unexpected , instead, which you'd get if you left off the id.

  4. hdgarrood commented on Feb 14, 2019

    @hdgarrood
    Contributor

    Shall we close this in favour of #3517?

  5. hdgarrood commented on May 8, 2019

    @hdgarrood
    Contributor

    I think this is safe to close unless we want to add tests for error positions, but that might be more effort than it's worth.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions