Skip to content

Fix Locale.aliases/2 and Timezone.timezone specs, call requested_locale_names with parens - #275

Open
lukaszsamson wants to merge 1 commit into
elixir-cldr:mainfrom
lukaszsamson:fix-spec-types
Open

lukaszsamson wants to merge 1 commit into
elixir-cldr:mainfrom
lukaszsamson:fix-spec-types

Conversation

@lukaszsamson

Copy link
Copy Markdown

Found with SpecLint on elixir 1.20.4

lib/cldr/locale.ex:2827: warning: Cldr.Locale.aliases/2: inferred return includes %Cldr.LanguageTag{
  ... (69 lines omitted) ...
    @spec aliases(locale_name() | String.t(), atom()) ::
  String.t() | [String.t()] | Cldr.LanguageTag.t() | nil
    inferred: (atom(), :region) -> dynamic(nil or binary() or non_empty_list(binary()))
    inferred: (term(), :language or :region or :script or :subdivision or :variant or :zone) -> dynamic(
  %Cldr.LanguageTag{
    language: binary(),
    language_subtags: empty_list(),
    script: nil,
    territory: nil,
    language_variants: empty_list(),
    locale: empty_map(),
    transform: empty_map(),
    extensions: empty_map(),
    private_use: list(binary()),
    requested_locale_name: binary(),
    canonical_locale_name: nil,
    cldr_locale_name: nil,
    rbnf_locale_name: nil,
    gettext_locale_name: nil,
    backend: nil
    ... (56 more lines omitted) ...
lib/cldr/timezone.ex:80: error: Cldr.Timezone.timezones_by_territory/0: inferred return %{
  ... (3213 lines omitted) ...
    @spec timezones_by_territory() :: %{
  SV: [timezone(), ...],
  EC: [timezone(), ...],
  SE: [timezone(), ...],
  GF: [timezone(), ...],
  TK: [timezone(), ...],
  CV: [timezone(), ...],
  PH: [timezone(), ...],
  MW: [timezone(), ...],
  TT: [timezone(), ...],
  NI: [timezone(), ...],
  LB: [timezone(), ...],
  LV: [timezone(), ...],
  GT: [timezone(), ...],
  JP: [timezone(), ...],
  NU: [timezone(), ...],
  LR: [timezone(), ...],
  LA: [timezone(), ...],
  SZ: [timezone(), ...],
  GN: [timezone(), ...],
    ... (1960 more lines omitted) ...
lib/cldr.ex:941: error: Cldr.requested_locale_names/1: no inferred clause accepts the arguments of this spec clause
    @spec requested_locale_names(backend()) :: [Cldr.Locale.locale_name(), ...] | []
    inferred: (%{..., requested_locale_names: term()}) -> dynamic()
ex_cldr 2.47.5: 180 spec clauses, 3 finding(s), 0 skipped

Findings are from the Hex package (ex_cldr 2.47.5); the repo itself needs CLDR_PRODUCTION data to compile, so the changes were not re-linted locally. Cldr.Locale.aliases("nlsx", :subdivision) #=> :SX, so atom() is added to the return spec. Entries in timezones_by_territory/0 carry a short_zone key, so the timezone type now has optional(:short_zone) (optional because timezones/0 values lack it). Cldr.requested_locale_names/1 now calls backend.requested_locale_names() with parens.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant