Fable: (dev 2.0) 0xFFFFFFFFu is read as 0u in REPL2

Created on 27 Aug 2018  路  7Comments  路  Source: fable-compiler/Fable

Description

0xFFFFFFFFu = 0u
````
evaluates true
### Repro code

0xFFFFFFFFu = 0u
````

Expected and actual results

expected: false
actual: true (repl2 and 2.0.0-beta-001))

Discussion

<> is consistent with = and also incorrect.

Any uint32 literal with bit 31 set exhibits this.

Workaround

(-1 |> uint32) is correct.

Related information

  • Fable version (dotnet fable --version): 2.0.0-beta-001
  • Operating system: windows

Most helpful comment

The OP issue seems to be somewhere in FCS-Fable (i.e. 0x1u comes across as 0u in the F# AST).
I'll take a deeper look, time permitting.

All 7 comments

The problem seems to be that the literal 0xFFFFFFFFu is read as 0u. I'd guess that it is interpreted as a negative int32 and then set to 0 on conversion to uint32 somewhere.

I have no idea where in the compiler code unsigned 32 bit literals are parsed (int32.ts does signed).

This is happening only in the REPL, right? Seems to work fine with the CLI version. Parsing the literal 0xFFFFFFFFu is done by the F# compiler so the code is not here. However that part is indeed compiled to JS when building the REPL so maybe there's an error in the process.

@ncave Do you have any idea what the problem may be here?

Apologies! Yes it is just the REPL (should have checked more carefully!).

No worries, it's understandable that users try quick things directly in the REPL (that's what is meant for) and finding disagreements between the REPL and the CLI is also helpful to pinpoint problems in JS compilation :+1:

Not a priority, since the CLI is fine.

But: 0x0FFFu gives a syntax error now in REPL2!

This number is outside the allowable range for 32-bit unsigned integers

@alfonsogarciacaro

The OP issue seems to be somewhere in FCS-Fable (i.e. 0x1u comes across as 0u in the F# AST).
I'll take a deeper look, time permitting.

Was this page helpful?
0 / 5 - 0 ratings