Fable: Char constructor should use fromCharCode

Created on 24 Apr 2016  路  5Comments  路  Source: fable-compiler/Fable

Description

The code char 97 is convert to (97).toString(), should be String.fromCharCode(97)

Expected behavior

char 97 = 'a'

Actual behavior

char 97 -> (97).toString() -> "97"

Known workarounds

I don't know any.

Related information

  • Operating system: Windows 10
  • Branch: Install from NPM - version 0.2.2
  • .NET Runtime 4.6.1
  • F# version 4.4

Most helpful comment

Thank you for the report!

Fixed in 35f6b4b5509da0626397d95421461cb7090469af.

Please take a look at it and let me know if this solves the problem for you.

All 5 comments

Another compilation issue:

``` f#
let charListToString chars =
System.String(List.toArray chars)

Convert to

``` js
var charListToString = exports.charListToString = function (chars) {
  return _fableCore.String.fsFormat(Array.from(chars));
};

I am using System.String, it is not related to String.fsFormat. :disappointed:

Workaround:

chars |> List.fold (fun s c -> s + c.ToString()) ""

Thank you for the report!

Fixed in 35f6b4b5509da0626397d95421461cb7090469af.

Please take a look at it and let me know if this solves the problem for you.

Thanks @fdcastel for fixing the string constructor, is that your changes fixing the char constructor too?

Yeah, the changes made by @fdcastel have also fixed various String constructors as you can see in the new unit tests :) I have published the new versions (fable-compiler 0.2.3 & fable-core 0.0.12). Please give them a try and feel free to close the issue if it's working.

OK, I will try that later. Thanks very much!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alfonsogarciacaro picture alfonsogarciacaro  路  26Comments

tomcl picture tomcl  路  26Comments

ed-ilyin picture ed-ilyin  路  48Comments

sergey-tihon picture sergey-tihon  路  70Comments

SCullman picture SCullman  路  49Comments