The documentation for the function Cldr.Unit.display_name/2 says that the first argument can be any unit name returned by Cldr.Unit.known_units/0, which returns a list of atoms. But the spec for Cldr.Unit.display_name/2 only specifies Cldr.Unit.value() | Cldr.Unit.t() as the first argument which causes a dialyzer warning when using an atom as the first argument.
The function call will not succeed.
MyRepo.Cldr.Unit.display_name(_unit :: atom(), [{:style, :narrow}])
will never return since the success typing is:
(
number()
| %{
:__struct__ => Cldr.Unit | Decimal,
:backend => _,
:base_conversion => [{atom() | [any()], map()}] | {[{_, _}], [{_, _}]},
:coef => _,
:exp => _,
:format_options => Keyword.t(),
:sign => _,
:unit => atom() | binary() | [atom()],
:usage => atom(),
:value => number() | %Decimal{:coef => _, :exp => _, :sign => _}
},
Keyword.t()
) :: binary() | {:error, {atom(), binary()}}
and the contract is
(Cldr.Unit.value() | Cldr.Unit.t(), Keyword.t()) ::
String.t() | {:error, {module(), binary()}}
The documentation for the function
Cldr.Unit.display_name/2
says that the first argument can be any unit name returned byCldr.Unit.known_units/0
, which returns a list of atoms. But the spec forCldr.Unit.display_name/2
only specifiesCldr.Unit.value() | Cldr.Unit.t()
as the first argument which causes a dialyzer warning when using an atom as the first argument.