Skip to content

More helpful error messagesΒ #56

@aaronjanse

Description

@aaronjanse

It would be great if rnix-parser has errors more descriptive than "unexpected X," perhaps prompting the user how to fix the code if we can guess what's missing (e.g. a semicolon for the last value in an attr set)?

Existing error messages at the time of writing:

#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum ParseError {
/// Unexpected is used when the cause cannot be specified further
Unexpected(TextRange),
/// UnexpectedExtra is used when there are additional tokens to the root in the tree
UnexpectedExtra(TextRange),
/// UnexpectedWanted is used when specific tokens are expected, but different one is found
UnexpectedWanted(SyntaxKind, TextRange, Box<[SyntaxKind]>),
/// UnexpectedDoubleBind is used when a pattern is bound twice
UnexpectedDoubleBind(TextRange),
/// UnexpectedEOF is used when the end of file is reached, while tokens are still expected
UnexpectedEOF,
/// UnexpectedEOFWanted is used when specific tokens are expected, but the end of file is reached
UnexpectedEOFWanted(Box<[SyntaxKind]>),
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions