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"
When encoding a nested struct, the fields are not properly ordered, causing the semantics to be lost.
Minimally working example:
Looking at the encoded form, this looks like
but it should have been something like: