When using a bits
or enum
variant as the value in a const
declaration, the type of the bits
/enum
value must be the same as the left-hand side of the const declaration:
{% include “docs/reference/fidl/language/error-catalog/label/_bad.md” %}
{% includecode gerrit_repo="fuchsia/fuchsia" gerrit_path="tools/fidl/fidlc/tests/fidl/bad/fi-0064.test.fidl" exclude_regexp="\/\/ (Copyright 20|Use of|found in).*" %}
One solution is to change the const
declaration's type to match that of the value being stored:
{% include “docs/reference/fidl/language/error-catalog/label/_good.md” %}
{% includecode gerrit_repo="fuchsia/fuchsia" gerrit_path="tools/fidl/fidlc/tests/fidl/good/fi-0064-a.test.fidl" exclude_regexp="\/\/ (Copyright 20|Use of|found in).*" %}
Alternatively, a different value can be selected to match the const
declaration's type:
{% include “docs/reference/fidl/language/error-catalog/label/_good.md” %}
{% includecode gerrit_repo="fuchsia/fuchsia" gerrit_path="tools/fidl/fidlc/tests/fidl/good/fi-0064-b.test.fidl" exclude_regexp="\/\/ (Copyright 20|Use of|found in).*" %}