Skip to content

Numeric format strings silently ignoring unsupported values or producing wrong results #4046

@kerams

Description

@kerams
let x = 100000
x.ToString "#,#" |> printfn "%s"
x.ToString "N0" |> printfn "%s"
printfn $"{x:N0}"

In fsi, this prints 3 identical lines based on the current culture.

In Fable, the result is

100,000
100000
%P(N0)
  • x.ToString "#,#" produces the correct string, but I'd appreciate a Fable warning saying that invariant culture will be used (I think I've seen something like that in other places).
  • x.ToString "N0" silently produces an incorrect string. An unsupported format error is warranted in my opinion.
  • $"{x:N0}" creates the compiled representation of the interpolation string, which is complete nonsense. An unsupported format error is warranted in my opinion.
  • Also $"{1000:``#,#``} items" results in %P(#,#) items.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions