[2.11.0] The generator doesn't warn about nested packed array of strings
zserio version: 2.11.0
01: package zs;
02:
03: struct PackedArray<T> {
04: varsize size;
05: packed T data[size];
06: };
07:
08: instantiate PackedArray<string> PackedArrayString;
09:
10: instantiate PackedArray<PackedArray<string>> PackedArray2String;
Parsing .\zs.zs
[WARNING] .\zs.zs:8:13: In instantiation of 'PackedArray' required from here
[WARNING] .\zs.zs:5:10: 'string' is not packable element type. [unpackable-array]
Expectations:
- [ok] warning about
PackedArray<string> - [NOK] warning about
PackedArray<PackedArray<string>>
If this is ok, what behavior should I expect? Will strings be packed with delta compression?
note: string is just an example of non-packable data.
I think this is expected behavior.
The warning about PackedArray<PackedArray<string>> is not there because you actually pack the instantiated structure
struct PackedArrayString
{
varsize size;
packed PackedArrayString data[size];
};
And this structure is packable because it contains at least one packable field size.
Yes, but for this case, it warns about nested packed strings:
01: package zs;
02:
03: struct PackedArray<T> {
04: varsize size;
05: packed T data[size];
06: };
07:
08: //instantiate PackedArray<string> PackedArrayString;
09:
10: instantiate PackedArray<PackedArray<string>> PackedArray2String;
[WARNING] .\zs.zs:10:25: In instantiation of 'PackedArray' required from here
[WARNING] .\zs.zs:5:10: 'string' is not packable element type. [unpackable-array]
So line 10 contains the warning, but the warning depends on something else (line 08).
It makes analysis harder than it should be :)
Please also note that in the line 10, PackedArrayString is not used directly.
Imagine something like this:
// fileA
struct PackedArray<T> {
varsize size;
packed T data[size];
};
// fileB
instantiate PackedArray<string> PackedArrayString; // <<< 'string' is not packable element type. [unpackable-array]
// fileC
subtype string Flowers;
// fileD
instantiate PackedArray<PackedArray<Flowers>> PackedArray2Flowers;
// fileE
instantiate PackedArray<PackedArray<string>> PackedArray2Strings;
It's hard to find manually that PackedArray2Flowers and PackedArray2Strings use PackedArrayString as a nested type.
If somebody decides to tolerate a single warning for PackedArrayString then other similar warnings will be hidden :(
Actually I have no idea how to check complex schemas manually :(
Maybe this is not an issue, and it could be transformed into an "idea".
If I got you correctly, I think your expectation is to have warning for each usage of instantiation not only for created instantiation.
In another words, zserio currently fires warning only on the place where the problematic instantiation is created not on the place where it is used:
package zs;
struct PackedArray<T>
{
varsize size;
packed T data[size];
};
instantiate PackedArray<string> PackedArrayString; // this instantiates template -> warning
instantiate PackedArray<PackedArray<string>> PackedArray2String; // this just uses already instantiated template from previous row -> no warning
For more info about instatiation you might consult the documentation.
If zserio should fire warning on each place where the problematic instantiation is used, then I am afraid of plenty of unnecessary warnings. But we can discuss.
Yep. "zserio currently fires warning only on the place where the problematic instantiation is created not on the place where it is used". That's what bothers me.
OK, I see. We will discuss it internally. Thanks a lot for sharing this idea.