zserio
zserio copied to clipboard
Update documentation of bitmask types that they does not have to be always prefixed
Discussed in https://github.com/ndsev/zserio/discussions/617
Originally posted by Danaozhong May 19, 2024
The zserio
specification about bitmasks states the following:
In expressions outside of the defining type, bitmask values must always be prefixed by the type name and a dot, e.g. Permission.WRITABLE.
This doesn't seem to apply to the isset()
operator, as the example provided shows that writing the following is possible:
return isset(testBitmask, INT);
This example also compiles with zserio
(tested version 2.11.0).
This code does not compile:
return ((testBitmask & INT) == TestBitmask.INT);
The isset()
example is not within the defining type, but omits the type name and dot. Based on the documentation of bitmask types, I would have expected only the following syntax to be legal:
return isset(testBitmask, TestBitmask.INT);
That feels a bit inconsistent to me. Of course, it makes sense that isset()
can deduce the bitmask type from the first operand, but it seems to contradict the documentation.