Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: you attempted to apply a function named :symbol_count on 1 #162

Closed
frahugo opened this issue Jan 17, 2024 · 2 comments
Closed

Error: you attempted to apply a function named :symbol_count on 1 #162

frahugo opened this issue Jan 17, 2024 · 2 comments

Comments

@frahugo
Copy link

frahugo commented Jan 17, 2024

Hi Kip,

We are migrating our app to the latest version of ex_money and related dependencies:

  cldr_utils 2.17.2 => 2.24.2
  ex_cldr 2.32.1 => 2.37.5
  ex_cldr_currencies 2.14.1 => 2.15.1
  ex_cldr_numbers 2.27.2 => 2.32.3
  ex_money 5.12.0 => 5.15.3
  ex_money_sql 1.7.1 => 1.10.2

In version 5.12.0 of ex_money, we were able to pass a custom format to Money.to_string():

> money = Money.new!("1234.567", :CAD)
Money.new(:CAD, "1234.567")
> Money.to_string(money, format: "#,##0.###;-#,##0.###", locale: :en)
{:ok, "1,234.57"}

But in the latest version (5.15.3), we get this error:

> money = Money.new!("1234.567", :CAD)
Money.new(:CAD, "1234.567")
> Money.to_string(money, format: "#,##0.###;-#,##0.###", locale: :en)
 
** (ArgumentError) you attempted to apply a function named :symbol_count on 1. If you are using Kernel.apply/3, make sure the module is an atom. If you are using the dot syntax, such as map.field or module.function(), make sure the left side of the dot is an atom or a map
    :erlang.apply(1, :symbol_count, [])
    (ex_cldr_numbers 2.32.3) lib/cldr/number/format/options.ex:757: Cldr.Number.Format.Options.expand_currency_symbol/2
    (ex_cldr_numbers 2.32.3) lib/cldr/number/format/options.ex:131: Cldr.Number.Format.Options.validate_options/3
    (ex_cldr_numbers 2.32.3) lib/cldr/number.ex:442: Cldr.Number.to_string/3

This is our Cldr module:

defmodule MyApp.Cldr do
  @moduledoc false

  use Cldr,
    locales: ["en", "fr"],
    default_locale: "en",
    providers: [Cldr.Number]
end
@kipcole9
Copy link
Owner

Fixed in ex_cldr_numbers version 2.32.4 with the following changelog entry. Thank you very much for report and sorry for the regression.

Bug Fixes

  • Fix formatting a number when a currency is specified but the format has no currency symbol. Closes ex_money 162.

@frahugo
Copy link
Author

frahugo commented Jan 18, 2024

@kipcole9 Thank you so much! solved our issue.

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

No branches or pull requests

2 participants