Skip to content

parser recovery should be much more conservative #1180

@sbillig

Description

@sbillig

The parser attempts to "recover" after a syntax error by searching forward for some expected token (eg the right paren when parsing a function parameter list); if it finds an instance of that token, it proceeds with parsing from that point onward (eg parses an optional return type annotation and function body), and reports an error.

We currently allow recovery on all sorts of tokens (like parens, braces, operators, etc). This can lead to an incorrect syntax tree, which we attempt to analyze, and then report misleading errors to the user.

We should only allow recovery on a select set of keywords (like struct, trait, etc), so that when we hit a syntax error and recover, we can be somewhat confident that the tree we produce from that point onward will be sensible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions