fable-compiler / repl-legacy

http://fable.io/repl
MIT License
14 stars 10 forks source link

UInt64.MaxValue = 0UL (at fable.io/repl) #1359 #36

Open CetinSert opened 6 years ago

CetinSert commented 6 years ago

Description

UInt64.MaxValue = 0UL holds true in Fable as imported on fable.io/repl:

Repro code

repl.it - F# 4 vs [fable.io/repl](http://fable.io/repl/#?code=open%20System%0Aopen%20Fable.Import.Browser%0A%0A%5B%3CLiteral%3E%5D%0Alet%20Z%20%3D%200UL%0A%5B%3CLiteral%3E%5D%0Alet%20I%20%3D%201UL%0Alet%20R%20%3D%20UInt64.MaxValue%0Alet%20X%20%3D%20UInt64.MaxValue%20-%20if%20Environment.OSVersion%20%3D%20null%20then%20I%20else%20Z%0A%0Alet%20init()%20%3D%0A%20%20let%20e%20%3D%20document.querySelector(%22pre%22)%20%3A%3F%3E%20HTMLCanvasElement%0A%20%20let%20t%20x%20%3D%20e.textContent%20%3C-%20e.textContent%20%2B%20%22%5Cn%22%20%2B%20sprintf%20%22%25A%22%20x%0A%20%20t%20%3C%7C%20(R%2CX%2CSystem.Environment.OSVersion)%0A%0Ainit()&html=%3Chtml%3E%0A%0A%3Chead%3E%0A%20%20%20%20%3Cmeta%20http-equiv%3D%22Content-Type%22%20content%3D%22text%2Fhtml%3Bcharset%3Dutf-8%22%3E%0A%3C%2Fhead%3E%0A%0A%3Cbody%3E%0A%20%20%20%20%3Cpre%3E%3C%2Fpre%3E%0A%3C%2Fbody%3E%0A%0A%3C%2Fhtml%3E%0A)

open System
open Fable.Import.Browser

[<Literal>]
let Z = 0UL
[<Literal>]
let I = 1UL
let R = UInt64.MaxValue
let X = UInt64.MaxValue - if Environment.OSVersion = null then I else Z

let init() =
  let e = document.querySelector("pre") :?> HTMLCanvasElement
  let t x = e.textContent <- e.textContent + "\n" + sprintf "%A" x
  t <| (R,X,System.Environment.OSVersion)

init()

Expected and actual results

UInt64.MaxValue = 0UL holds true; it should not.

Related information

https://github.com/fable-compiler/Fable/blob/master/src/js/fable-core/Long.ts https://github.com/dcodeIO/long.js/blob/master/src/long.js - testing this Long.MAX_UNSIGNED_VALUE.toString() = "18446744073709551615"

MangelMaxime commented 6 years ago

For reference, https://github.com/fable-compiler/Fable/issues/1359

CetinSert commented 6 years ago

@MangelMaxime @alfonsogarciacaro what is the recommended way to know if a piece of code is running in Fable?