| ## fi-0145: Attribute typo {:#fi-0145} |
| |
| An attribute name whose spelling is too similar to one of FIDL's official |
| [attributes][docs-fidl-attributes] will result in a compiler warning: |
| |
| {% 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-0145.test.fidl" exclude_regexp="\/\/ (Copyright 20|Use of|found in).*" %} |
| ``` |
| |
| In the above example, the attribute `@duc` is too similar in spelling to the |
| official FIDL attribute `@doc`. In cases like this, the attribute naming is |
| intentional, and not an accidental misspelling of an official FIDL attribute, it |
| should be modified to be sufficiently unique: |
| |
| {% 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-0145.test.fidl" exclude_regexp="\/\/ (Copyright 20|Use of|found in).*" %} |
| ``` |
| |
| Besides spell checking, the purpose of this warning is to discourage using |
| names that are too similar to official FIDL attributes. |
| |
| The typo detection algorithm works by calculating the [edit |
| distance][wiki-edit-distance] of the attribute name from every official FIDL |
| attribute. Names that are too similar, defined as having too small of an edit |
| distance, trigger the typo detector. |
| |
| [docs-fidl-attributes]: /docs/reference/fidl/language/attributes.md |
| [wiki-edit-distance]: https://en.wikipedia.org/wiki/Edit_distance |