A declaration cannot have the same name as a library imported with using
:
{% include “docs/reference/fidl/language/error-catalog/label/_bad.md” %}
{% includecode gerrit_repo="fuchsia/fuchsia" gerrit_path="tools/fidl/fidlc/tests/fidl/bad/fi-0038-a.test.fidl" exclude_regexp="\/\/ (Copyright 20|Use of|found in).*" %}
{% includecode gerrit_repo="fuchsia/fuchsia" gerrit_path="tools/fidl/fidlc/tests/fidl/bad/fi-0038-b.test.fidl" exclude_regexp="\/\/ (Copyright 20|Use of|found in).*" %}
Instead, import the library under a different name with the using
... as
syntax:
{% include “docs/reference/fidl/language/error-catalog/label/_good.md” %}
{% includecode gerrit_repo="fuchsia/fuchsia" gerrit_path="tools/fidl/fidlc/tests/fidl/good/fi-0038-b.test.fidl" exclude_regexp="\/\/ (Copyright 20|Use of|found in).*" %}
Alternatively, rename the declaration to avoid the conflict:
{% include “docs/reference/fidl/language/error-catalog/label/_good.md” %}
{% includecode gerrit_repo="fuchsia/fuchsia" gerrit_path="tools/fidl/fidlc/tests/fidl/good/fi-0038-c.test.fidl" exclude_regexp="\/\/ (Copyright 20|Use of|found in).*" %}
You can avoid this problem by using multiple components in library names. For example, FIDL libraries in the Fuchsia SDK start with fuchsia.
, so they have at least two components and cannot conflict with declaration names.
This error exists to prevent ambiguities. For example, if dependency
were an enum with a member called VALUE
, it would be ambiguous whether dependency.VALUE
referred to that enum member or to the const declared in the imported library.