A constant value must be of a type appropriate for the location it is being used.
The most common cause for this error is when a const
declaration's value does not match its stated type:
{% include “docs/reference/fidl/language/error-catalog/label/_bad.md” %}
{% includecode gerrit_repo="fuchsia/fuchsia" gerrit_path="tools/fidl/fidlc/tests/fidl/bad/fi-0065-a.test.fidl" exclude_regexp="\/\/ (Copyright 20|Use of|found in).*" %}
This can still be problematic when a correctly defined const
value is used in a location where its underlying type is invalid:
{% include “docs/reference/fidl/language/error-catalog/label/_bad.md” %}
{% includecode gerrit_repo="fuchsia/fuchsia" gerrit_path="tools/fidl/fidlc/tests/fidl/bad/fi-0065-b.test.fidl" exclude_regexp="\/\/ (Copyright 20|Use of|found in).*" %}
Additionally, FIDL's official check their arguments against a schema. Because these arguments are themselves constant values, the same kind of type mismatch can occur:
{% include “docs/reference/fidl/language/error-catalog/label/_bad.md” %}
{% includecode gerrit_repo="fuchsia/fuchsia" gerrit_path="tools/fidl/fidlc/tests/fidl/bad/fi-0065-c.test.fidl" exclude_regexp="\/\/ (Copyright 20|Use of|found in).*" %}
In all of these cases, the solution is to use only use values of the expected type in locations where const
values are accepted. The above cases become, respectively:
{% include “docs/reference/fidl/language/error-catalog/label/_good.md” %}
{% includecode gerrit_repo="fuchsia/fuchsia" gerrit_path="tools/fidl/fidlc/tests/fidl/good/fi-0065-a.test.fidl" exclude_regexp="\/\/ (Copyright 20|Use of|found in).*" %}
{% include “docs/reference/fidl/language/error-catalog/label/_good.md” %}
{% includecode gerrit_repo="fuchsia/fuchsia" gerrit_path="tools/fidl/fidlc/tests/fidl/good/fi-0065-b.test.fidl" exclude_regexp="\/\/ (Copyright 20|Use of|found in).*" %}
{% include “docs/reference/fidl/language/error-catalog/label/_good.md” %}
{% includecode gerrit_repo="fuchsia/fuchsia" gerrit_path="tools/fidl/fidlc/tests/fidl/good/fi-0065-c.test.fidl" exclude_regexp="\/\/ (Copyright 20|Use of|found in).*" %}