| ## fi-0124: Custom attribute argument must be string or bool {:#fi-0124} |
| |
| The arguments on user-defined FIDL attributes are limited to being string or |
| boolean types: |
| |
| {% 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-0124.test.fidl" exclude_regexp="\/\/ (Copyright 20|Use of|found in).*" %} |
| ``` |
| |
| {% 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-0124.test.fidl" exclude_regexp="\/\/ (Copyright 20|Use of|found in).*" %} |
| ``` |
| |
| Unlike [official attributes][docs-fidl-attributes], the schema of user defined |
| attributes is not known to the compiler. Because of this, it is impossible for |
| the compiler to deduce the type of any given numeric argument - is `2` an |
| `int8`, a `uint64`, or a `float32`? There's no way for the compiler to know. |
| |
| A possible solution to this problem would be to implement a first-class |
| `numeric` type in the JSON IR for ambiguous cases like these. However, because |
| custom attribute arguments are the only known use case for this today, this |
| feature has not been prioritized. |
| |
| [docs-fidl-attributes]: /docs/reference/fidl/language/attributes.md |