Skip to content

Format parse errors better #632

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 23, 2020
Merged

Conversation

camelid
Copy link
Member

@camelid camelid commented Oct 23, 2020

Previously the parser printed parse errors with Debug formatting, even
though Display formatting is implemented and looks much better.

Before:

?- load libstd.chalk
?- forall<T: Clone> { Vec<T>: Clone }
error: parse error: UnrecognizedToken { token: (8, Token(17, ":"), 9), expected: ["\",\"", "\">\""] }
position: `forall<T: Clone> { Vec<T>: Clone }`
                   ^

After:

?- load libstd.chalk
?- forall<T: Clone> { Vec<T>: Clone }
error: parse error: Unrecognized token `:` found at 8:9
Expected one of "," or ">"
position: `forall<T: Clone> { Vec<T>: Clone }`
                   ^

Previously the parser printed parse errors with Debug formatting, even
though Display formatting is implemented and looks much better.

Before:

    ?- load libstd.chalk
    ?- forall<T: Clone> { Vec<T>: Clone }
    error: parse error: UnrecognizedToken { token: (8, Token(17, ":"), 9), expected: ["\",\"", "\">\""] }
    position: `forall<T: Clone> { Vec<T>: Clone }`
                       ^

After:

    ?- load libstd.chalk
    ?- forall<T: Clone> { Vec<T>: Clone }
    error: parse error: Unrecognized token `:` found at 8:9
    Expected one of "," or ">"
    position: `forall<T: Clone> { Vec<T>: Clone }`
                       ^
@camelid camelid force-pushed the better-parse-errors branch from fd3db50 to 613e664 Compare October 23, 2020 02:30
@jackh726
Copy link
Member

@bors r+

thanks!

@bors
Copy link
Contributor

bors commented Oct 23, 2020

📌 Commit 613e664 has been approved by jackh726

@bors
Copy link
Contributor

bors commented Oct 23, 2020

⌛ Testing commit 613e664 with merge a698320...

@bors
Copy link
Contributor

bors commented Oct 23, 2020

☀️ Test successful - checks-actions
Approved by: jackh726
Pushing a698320 to master...

@bors bors merged commit a698320 into rust-lang:master Oct 23, 2020
@camelid camelid deleted the better-parse-errors branch October 23, 2020 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants