| ## fi-0071: Unknown attribute disallowed on strict enum members {:#fi-0071} |
| |
| A `strict enum` must not have any members annotated with the `@unknown` |
| attribute: |
| |
| {% 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-0071.test.fidl" exclude_regexp="\/\/ (Copyright 20|Use of|found in).*" %} |
| ``` |
| |
| To continue using the `@unknown` attribute, change to a `flexible enum`: |
| |
| {% 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-0071-a.test.fidl" exclude_regexp="\/\/ (Copyright 20|Use of|found in).*" %} |
| ``` |
| |
| Otherwise, just remove the attribute altogether to remain a `strict enum`: |
| |
| {% 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-0071-b.test.fidl" exclude_regexp="\/\/ (Copyright 20|Use of|found in).*" %} |
| ``` |
| |
| The purpose of the `@unknown` [attribute][docs-fidl-attributes-unknown] is to |
| smooth over a transition from a `strict enum` with a user-defined unknown value, |
| like this into a `flexible enum` with unknown values known to and handled by |
| FIDL. In the above example, it would be used to transition from the second |
| correct usage to the first one. |
| |
| [docs-fidl-attributes-unknown]: /docs/reference/fidl/language/attributes.md#unknown |