When an array in yaml has structs with different fields, the code crashes when ConvertToArray is true.
Basically, the elementsHaveConsistentType forgets to check that structs have matching fields.
To reproduce the bug, you can run the following matlab code:
% two dissimilar structs inside a cell array
data = {struct("a",1) struct("b",2)};
% dump to yaml and load back in
yaml_str = yaml.dump(data);
data_test = yaml.load(yaml_str,ConvertToArray=true);
which will generate the following error:
Error using horzcat
Names of fields in structure arrays being concatenated do not match. Concatenation of structure arrays
requires that these arrays have the same set of fields.
Error in yaml.load/convertList (line 111)
result = horzcat(result{:});
Error in yaml.load/convert (line 71)
result = convertList(node);
Error in yaml.load (line 48)
result = convert(rootNode);
Error in untitled (line 10)
data_test = yaml.load(yaml_str,ConvertToArray=true);
When an array in yaml has structs with different fields, the code crashes when ConvertToArray is true. Basically, the
elementsHaveConsistentType
forgets to check that structs have matching fields.To reproduce the bug, you can run the following matlab code:
which will generate the following error: