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

Runtime implementation of built-in operator "isset" does not support OR operator #626

Closed
hannesscharmann-tomtom opened this issue Jun 12, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@hannesscharmann-tomtom
Copy link

Zserio version and language
Zserio: 2.14.0
Language: C++/Java/Python

Describe the bug
The implemenation of BuiltInOperators.isSet(ZserioBitmask a, ZserioBitmask b) always assumes that all bits of b must be set in a (i.e. AND combines the two values). Zserio language specification however, allows the usage of AND, OR, and also a combination of both operators. This is why a condition like if isset(content, MyBitMask.A | MyBitMask.B) (with bitmask varuint32 MyBitMask) only evaluates to true if both bits are set.

How to reproduce
Steps to reproduce the behavior:

  • Example schema
bitmask varuint32 MyBitMask
{
    A,
    B
};

struct MyStruct
{
    MyBitMask content;
    string myOptionalField if isset(content, MyBitMask.A | MyBitMask.B);
};
  • Sample code (*.cpp / *.java / *.py)
public boolean isMyOptionalFieldUsed()
{
    return (zserio.runtime.BuiltInOperators.isSet(getContent(), MyBitMask.Values.A.or(MyBitMask.Values.B)));
}
  • Error
    isMyOptionalFieldUsed() returns false when only one of the two bits (A OR B) is set in bitmask content.

Expected behavior
The implementation of the isset operator shall support OR operators and also combinations of AND and OR operators.

Additional context
n/a

@hannesscharmann-tomtom hannesscharmann-tomtom added the bug Something isn't working label Jun 12, 2024
@mikir
Copy link
Contributor

mikir commented Jun 13, 2024

Operator isset is implemented as defined.

@mikir mikir closed this as not planned Won't fix, can't repro, duplicate, stale Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants