elixir-cldr / cldr

Elixir implementation of CLDR/ICU
Other
447 stars 33 forks source link

Locale.locale_name type #167

Closed alappe closed 2 years ago

alappe commented 2 years ago

Cldr.put_locale/2 uses the is_locale_name guard:

defguard is_locale_name(locale_name) when is_atom(locale_name) or is_binary(locale_name)

but is typed:

 @spec put_locale(backend(), Locale.locale_name() | LanguageTag.t()) :: {:ok, LanguageTag.t()} | {:error, {module(), String.t()}}

where Locale.locale_name is typed:

@type locale_name() :: atom()

I'm getting an error using put_locale/2 with binary locale names. But reading the guard, this should be valid and the typing of locale_name should be @type locale_name() :: atom() | String.t().

kipcole9 commented 2 years ago

Fixed in commit e075eb081 and published as ex_cldr version 2.26.2 with the following changelog entry:

Bug Fixes

Thanks for the report and collaboration and apologies for the inconvenience. I've added a function to dev/cldr_backend.ex to ensure dialyzer can check the type in my CI.