Skip to content
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

Missing commas produce unhelpful errors with col/line 0 #265

Closed
WaffleLapkin opened this issue Aug 5, 2020 · 1 comment · Fixed by #353
Closed

Missing commas produce unhelpful errors with col/line 0 #265

WaffleLapkin opened this issue Aug 5, 2020 · 1 comment · Fixed by #353
Labels

Comments

@WaffleLapkin
Copy link
Contributor

This code:

    #[derive(serde::Deserialize)]
    struct Test {
        a: i32,
        b: i32,
    }
    let string = r#"Test(
        a: 1 // <-- forgetten comma here
        b: 2
    )"#;

    ron::from_str::<Test>(string).unwrap();

Produces the following error:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { code: Message("missing field `b`"), position: Position { col: 0, line: 0 } }', src/main.rs:67:35

Which is really hard to understand because

  1. it says field b is missing but it doesn't
  2. it doesn't say anything about commas
  3. it points to 0, 0
@kvark kvark added the bug label Aug 5, 2020
@kvark
Copy link
Collaborator

kvark commented Aug 5, 2020

On a more general note, I was wondering if we could integrate https://github.com/brendanzab/codespan for proper error reporting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants