blob: 3c5240cf298ae5fedb1ba40386e9940c24b496d7 [file] [log] [blame] [view]
## fi-0068: Flexible enums have a reserved unknown value {:#fi-0068}
<!-- TODO(https://fxbug.dev/42061758): Update this example when renaming @unknown
to @unknown_for_transitioning_strict_to_flexible -->
This error happens when you define an enum member whose value clashes with the
reserved unknown value.
Flexible enums may hold values not known by the FIDL schema. In addition,
flexible enums always reserve some value which will be treated as unknown.
By default, that value is the maximum numerical value representable by the
underlying integer type of that enum (e.g. `255` in case of `uint8`).
{% include "docs/reference/fidl/language/error-catalog/label/_bad.md" %}
```fidl
{% includecode gerrit_repo="fuchsia/fuchsia" gerrit_path="tools/fidl/fidlc/tests/fidl/bad/fi-0068.test.fidl" exclude_regexp="\/\/ (Copyright 20|Use of|found in).*" %}
```
To fix the error, you may remove the member or change its value:
{% include "docs/reference/fidl/language/error-catalog/label/_good.md" %}
```fidl
{% includecode gerrit_repo="fuchsia/fuchsia" gerrit_path="tools/fidl/fidlc/tests/fidl/good/fi-0068-a.test.fidl" exclude_regexp="\/\/ (Copyright 20|Use of|found in).*" %}
```
```fidl
{% includecode gerrit_repo="fuchsia/fuchsia" gerrit_path="tools/fidl/fidlc/tests/fidl/good/fi-0068-b.test.fidl" exclude_regexp="\/\/ (Copyright 20|Use of|found in).*" %}
```
Finally, if you come across this error when transitioning a `strict` enum to a
`flexible` enum, you may use the `@unknown` attribute to designate the numerical
value of a particular member as the unknown value. See [`@unknown`][unknown].
[unknown]: /docs/reference/fidl/language/attributes.md#unknown