Skip to content

Inconsistent handling of enumerations #8833

@jtdavis777

Description

@jtdavis777

While writing up a fix to #8311, I found an odd quirk of the language that I'd like to just bring up for discussion/clarification:

enum NonZero: ubyte {
  A = 1
}

table Data {
  one: NonZero = A;  // totally fine, expected behavior
  two: NonZero;  // flatc fails to generate with "error: default value of `0` for field `non_zero_default_enum` is not part of enum `NonZeroDefaultEnum`"
  three: [NonZero];  // totally fine, expected behavior
}

struct NonZeroStruct {
  arr: [NonZero:4];  // compiles???
}

This is currently shipping behavior, and receiving buffers with 0 as a value is not an issue, but I don't think we have a consistent or documented strategy for how to handle this case, especially across languages and generated object APIs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions