zserio icon indicating copy to clipboard operation
zserio copied to clipboard

Consider to fire warning in case of access to choice field

Open mikir opened this issue 1 year ago • 0 comments

The following schema shows an example of access to the choice field (see it in streamlit):

package sample;

choice Choice(uint8 selector) on selector
{
    case 0:
        uint32 value;
    default:
        string text;
};

struct Main
{
    uint8 selector;
    Choice(selector) choiceField;
    uint32 id : id != choiceField.value;
};

There is a constraint id != choiceField.value which accesses the choice field value without explicit check of choice selector (should be always 0).

It would be good to fire at least warning that such construct can be dangerous.

mikir avatar Feb 20 '24 12:02 mikir