From 99d88a3f7b7870656b85fdb25b5383d5e047a63c Mon Sep 17 00:00:00 2001 From: Kip Cole Date: Thu, 11 Apr 2024 04:48:36 +1000 Subject: [PATCH] Fix spec for display_name/2. Closes #43 --- CHANGELOG.md | 8 ++++++++ lib/cldr/unit.ex | 2 +- lib/cldr/unit/backend.ex | 2 +- mix.exs | 2 +- mix/for_dialyzer.ex | 9 +++++++++ 5 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 mix/for_dialyzer.ex diff --git a/CHANGELOG.md b/CHANGELOG.md index 7037815..8c096c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## Cldr_Units v3.16.5 + +This is the changelog for Cldr_units v3.16.4 released on April 11th, 2024. For older changelogs please consult the release tag on [GitHub](https://github.com/elixir-cldr/cldr_units/tags) + +### Bug Fixes + +* Fix spec for `Cldr.Unit.display_name/2`. Thanks to @ryotsu for the report. Closes #43. + ## Cldr_Units v3.16.4 This is the changelog for Cldr_units v3.16.4 released on November 2nd, 2023. For older changelogs please consult the release tag on [GitHub](https://github.com/elixir-cldr/cldr_units/tags) diff --git a/lib/cldr/unit.ex b/lib/cldr/unit.ex index 5e93da0..987fe1f 100644 --- a/lib/cldr/unit.ex +++ b/lib/cldr/unit.ex @@ -1604,7 +1604,7 @@ defmodule Cldr.Unit do "l" """ - @spec display_name(Cldr.Unit.value() | Cldr.Unit.t(), Keyword.t()) :: + @spec display_name(translatable_unit() | t(), Keyword.t()) :: String.t() | {:error, {module, binary}} def display_name(unit, options \\ []) diff --git a/lib/cldr/unit/backend.ex b/lib/cldr/unit/backend.ex index 776ad59..60d07e7 100644 --- a/lib/cldr/unit/backend.ex +++ b/lib/cldr/unit/backend.ex @@ -413,7 +413,7 @@ defmodule Cldr.Unit.Backend do "l" """ - @spec display_name(Cldr.Unit.value() | Cldr.Unit.t(), Keyword.t()) :: + @spec display_name(Cldr.Unit.translatable_unit() | Cldr.Unit.t(), Keyword.t()) :: String.t() | {:error, {module, binary}} def display_name(unit, options \\ []) do diff --git a/mix.exs b/mix.exs index be81bcf..6ebe0f6 100644 --- a/mix.exs +++ b/mix.exs @@ -1,7 +1,7 @@ defmodule Cldr.Units.Mixfile do use Mix.Project - @version "3.16.4" + @version "3.16.5" def project do [ diff --git a/mix/for_dialyzer.ex b/mix/for_dialyzer.ex new file mode 100644 index 0000000..9bb753a --- /dev/null +++ b/mix/for_dialyzer.ex @@ -0,0 +1,9 @@ +defmodule Cldr.Unit.Dialyzer do + def display_name do + MyApp.Cldr.Unit.display_name(:kilogram) + MyApp.Cldr.Unit.display_name(Cldr.Unit.new!(:foot, 1)) + + Cldr.Unit.display_name(:kilogram, backend: MyApp.Cldr) + Cldr.Unit.display_name(Cldr.Unit.new!(:foot, 1), backend: MyApp.Cldr) + end +end \ No newline at end of file