Skip to content

Parser backtracking issues with nested arrays #2690

Description

@natefaubion

http://try.purescript.org/?gist=e22c2b96c145d7c475ce4f26bc473704

render a =
  [ Left "One"
  , Right
      [ Left "Two"
      , { foo = 1 }
      ]
  ]
 Unable to parse module:
  unexpected [
  expecting , or ]

But if you remove the nesting, it's a better error

render a =
  [ Left "Two"
  , { foo = 1 }
  ]
 Unable to parse module:
  unexpected =
  expecting :, , or }

Activity

  1. natefaubion commented on Feb 23, 2017

    @natefaubion
    ContributorAuthor

    Originally, the issue manifested for me with record binders in a case statement. But it seems to be an issue with nested arrays in general.

  2. added this to the 1.0 milestone on Feb 23, 2017
  3. paf31 commented on Mar 11, 2017

    @paf31
    Contributor

    I've made multiple attempts to fix this, but all of them have involved non-trivial changes to the AST to avoid backtracking, and none of them have quite worked how I would like. I'm going to suggest this wait until we can move away from Parsec and towards something with better support for automatically left-factoring the grammar.

  4. modified the milestones: Approved, 1.0 on Mar 19, 2017
  5. hdgarrood commented on May 7, 2019

    @hdgarrood
    Contributor

    Now that the cst parser has been merged the error is better:

    Error found:
    at example.purs:6:15 - 6:16 (line 6, column 15 - line 6, column 16)
    
      Unable to parse module:
      Expected ':', saw '='
    
    
    See https://github.com/purescript/documentation/blob/master/errors/ErrorParsingModule.md for more information,
    or to contribute content related to this error.
    

    so I think this can be closed.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions