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

if parse error happens at end-of-line, no span is given #234

Open
duckinator opened this issue Dec 4, 2024 · 0 comments
Open

if parse error happens at end-of-line, no span is given #234

duckinator opened this issue Dec 4, 2024 · 0 comments

Comments

@duckinator
Copy link
Contributor

E.g., when implementing YAML support, this testcase fails because more content is expected after goodbye:, so it points at column 9... in an 8-column line.

I feel like it'd still be useful to show that information.

#[test]
#[cfg(feature = "yaml-serde")]
fn yaml_invalid() {
    use axoasset::AxoassetError;

    #[derive(serde::Deserialize, PartialEq, Eq, Debug)]
    struct MyType {
        hello: String,
        goodbye: bool,
    }

    // Make the file
    let contents = String::from(
        r##"
hello: "there"
goodbye:
"##,
    );
    let source = axoasset::SourceFile::new("file.yml", contents);

    let res = source.deserialize_yaml::<MyType>();
    assert!(res.is_err());
    println!("{:#?}", res);
    let Err(AxoassetError::Yaml { span: Some(_), .. }) = res else {
        panic!("span was invalid");
    };
}
@duckinator duckinator changed the title if parse error happens at end-of-line, no information is given if parse error happens at end-of-line, no span is given Dec 4, 2024
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

No branches or pull requests

1 participant