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

gbc accepts enum fields without default values #177

Closed
chwarr opened this issue Jun 10, 2016 · 3 comments
Closed

gbc accepts enum fields without default values #177

chwarr opened this issue Jun 10, 2016 · 3 comments
Labels

Comments

@chwarr
Copy link
Member

chwarr commented Jun 10, 2016

Enum fields must have an explicit default value:

Enum fields must have an explicit default value which must be one of the enum named constants.

However, gbc accepts the following .bond file:

namespace enum_without_default;

enum Color
{
    Orange = 1,
    Yellow = 2,
}

struct Val
{
  1: Color color;
}

The following is also accepted even though it shouldn't be.

...
struct Val
{
  1: Color color = 12345;
}
...
@chwarr chwarr added the bug label Jun 10, 2016
@lalo
Copy link
Member

lalo commented Jun 14, 2016

should nothing be valid for enums?

struct Val
{
  1: Color color = nothing;
}

@chadwalters
Copy link
Contributor

Yes, I think nothing should be valid for enums.

lalo added a commit that referenced this issue Jun 17, 2016
- Fail when struct field has default value of 'nothing'
- Fail when enum field doesn't have default value
- Validate aliases' default value
- Validate default value type mistmatches
- Validate default value out-of-range values

Fixes #177, fixes #164, fixes #128, fixes #73, fixes #72
lalo added a commit that referenced this issue Jun 22, 2016
- Validate default value type mistmatches (fixes #72, fixes #128)
- Validate default value out-of-range values (fixes #73)
- Fail when struct field has default value of 'nothing' (fixes #164)
- Fail when enum field doesn't have default value (fixes #177)
- Validate default value of type aliases
@lalo lalo closed this as completed in 90b8bad Jun 22, 2016
@chwarr
Copy link
Member Author

chwarr commented Aug 23, 2016

Bond version 4.3.0 is now live on NuGet.org. These changes are included in that version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants