Skip to content

Round-trip failure: Empty maps/sequences gain an extra layer of nesting #338

@saethlin

Description

@saethlin

This example program probably ought to exit successfully

fn main() {
    let input = "{}";
    let v: ron::Value = ron::from_str(input).unwrap();
    println!("{:?}", v);
    let ser = ron::to_string(&v).unwrap();
    println!("{:?}", ser);
    let roundtrip = ron::from_str(&ser).unwrap();
    println!("{:?}", roundtrip);
    assert_eq!(v, roundtrip);
}

But it doesn't:

Map(Map({}))
"({})"
Seq([Map(Map({}))])
thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `Map(Map({}))`,
 right: `Seq([Map(Map({}))])`', src/main.rs:9:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

This actually continues indefinitely. "{}" becomes "({})" which becomes "[({})]" and from then on we just add square brackets every round-trip.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions