Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disallow most of the expressions in offsets #641

Closed
mikir opened this issue Jun 21, 2024 · 1 comment
Closed

Disallow most of the expressions in offsets #641

mikir opened this issue Jun 21, 2024 · 1 comment
Assignees
Labels
core Zserio core module enhancement New feature or request
Milestone

Comments

@mikir
Copy link
Contributor

mikir commented Jun 21, 2024

Consider the following schema:

struct Schema
{
    uint32 myOffsetArray[];
    uint8 someValue;
myOffsetArray[@index % someValue]:
    string stringArray[];
};

Such schema is not possible to validate during the zserio compilation. It can be valid in some cases. In all cases, it smells because the offsets in myOffsetArray can be easily overwrite.

Because we can not think of any meaningful use case that would require this, we suggest to completely disable offset expressions except of the simple [@index].

For more info, please have a look to the issue #640.

@mikir mikir added enhancement New feature or request core Zserio core module labels Jun 21, 2024
@mikir mikir added this to the 2.15 milestone Jun 21, 2024
@Mi-La Mi-La changed the title Offset expressions should be disabled Expressions in Indexed Offsets should be disabled Aug 14, 2024
@mikir
Copy link
Contributor Author

mikir commented Aug 15, 2024

Don't forget to update the Zserio Language Overview documentation where the description of offsets is quite vague.

@Mi-La Mi-La changed the title Expressions in Indexed Offsets should be disabled Offset expressions should be disabled Aug 16, 2024
@Mi-La Mi-La changed the title Offset expressions should be disabled Disallow most of the expressions in offsets Aug 19, 2024
Mi-La added a commit that referenced this issue Aug 19, 2024
@Mi-La Mi-La closed this as completed Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Zserio core module enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants