Skip to content

Nested structs are not properly encoded #3

@egeerardyn

Description

@egeerardyn

When encoding a nested struct, the fields are not properly ordered, causing the semantics to be lost.

Minimally working example:

in = struct('a','a','b',struct('c_in_b','c_in_b'),'e','e');
nested_in = struct('in',in);

% source = in;  % one level of nesting goes fine
source = nested_in;  % the second level of nested structs will break things

encoded = toml.encode(source);
decoded = toml.decode(encoded);

assert(isequal(decoded, source), 'Encoding/Decoding should be inverse operations!');

Looking at the encoded form, this looks like

[in]
a = "a"

[in.b]
c_in_b = "c_in_b"
e = "e"

but it should have been something like:

[in]
a = "a"
e = "e"

[in.b]
c_in_b = "c_in_b"

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions