Skip to content

Error Recovery #6702

@babel-bot

Description

@babel-bot

Issue originally reported by @thejameskyle in babel/babylon#347

Right now whenever Babylon comes across a syntax error it immediately throws an error and tosses out the AST. While this is okay for a compiler pipeline where we want don't want to attempt transforming a broken AST, it's not okay for other types of tooling.

For example, there's plenty of tooling that needs to run in your editor while you are typing. If you are in the middle of typing code, you often have a half-finished/invalid program. But this is when editor tooling is most useful because a lot of it's there to help finish what you're typing.

I think the best way to approach this would be to start by removing all the throw-s from the parser code and replace them by pushing to an errors array. Then we can start to identify all the places where we'll have to make a decision on how to continue building the AST.

Metadata

Metadata

Assignees

No one assigned

    Labels

    importedoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issuepkg: parser

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions