Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.

Octal literal is deserialized as decimal #134

Closed
isegal opened this issue Aug 24, 2019 · 2 comments
Closed

Octal literal is deserialized as decimal #134

isegal opened this issue Aug 24, 2019 · 2 comments

Comments

@isegal
Copy link

isegal commented Aug 24, 2019

When passing an octal number as per specification at https://yaml.org/refcard.html
The value does not get parsed as octal.

Ex:

#[test]
fn test_octal_deserialize() {
    let source = r#"
---
value: 0755
"#;
    #[derive(Serialize, Deserialize, PartialEq, Debug)]
    struct TestOctal {
        value: u32,
    }
    let result: TestOctal = serde_yaml::from_str(&source).unwrap();
    assert_eq!(result, TestOctal{
        value: 0o755
    });
}

Expected :TestOctal { value: 493 }
Actual :TestOctal { value: 755 }

@dtolnay
Copy link
Owner

dtolnay commented Aug 25, 2019

That link describes yaml 1.1. This library implements yaml 1.2 which uses 0o prefix for octal.

---
value: 0o755

@isegal
Copy link
Author

isegal commented Aug 25, 2019

Just tested with 0o prefix. Works as expected. Thank you.

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

Successfully merging a pull request may close this issue.

2 participants