| ## fi-0035: Canonical name collision {:#fi-0035} |
| |
| Two declarations cannot have the same canonical name: |
| |
| {% 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-0035.test.fidl" exclude_regexp="\/\/ (Copyright 20|Use of|found in).*" %} |
| ``` |
| |
| Even though `COLOR` and `Color` look different, they are both represented by the |
| **canonical** name `color`. You get the canonical name by converting the |
| original name to `snake_case`. |
| |
| To fix the error, give each declaration a name that is unique after |
| canonicalization: |
| |
| {% 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-0035.test.fidl" exclude_regexp="\/\/ (Copyright 20|Use of|found in).*" %} |
| ``` |
| |
| Following the [FIDL style guide][fidl-style-naming]'s naming guidelines will |
| minimize your chances of running into this error. Canonical name collisions will |
| never happen between declarations that use the same casing style, and they will |
| rarely happen between ones that use different styles because of other |
| requirements (e.g. protocol names should usually be noun phrases ending in -er). |
| |
| FIDL enforces this rule because bindings generators transform names to the |
| idiomatic naming style for the target language. By ensuring unique canonical |
| names, we guarantee that bindings can do this without producing name collisions. |
| See [RFC-0040: Identifier uniqueness][RFC-0040] for more details. |
| |
| [fidl-style-naming]: /docs/development/languages/fidl/guides/style.md#names |
| [RFC-0040]: /docs/contribute/governance/rfcs/0040_identifier_uniqueness.md |