fsbolero / TryFSharpOnWasm

F# Compiler running in WebAssembly with Bolero
Apache License 2.0
38 stars 3 forks source link

Complaints about missing `System.Globalization` assembly #9

Open vilinski opened 4 years ago

vilinski commented 4 years ago

The following code brings the compiler error:

Compilation failed.
(22,8)-(22,13) The type referenced through 'System.Globalization.CultureInfo' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Globalization'.
printfn "Hello, world!"

let mul a b = a * b

let a = 42
let b = 2
let c = mul a b
printfn "%i * %i = %i" a b c

type Calculation =
    | Literal of int
    | Mul of Calculation * Calculation
    | Plus of Calculation * Calculation
    | Minus of Calculation * Calculation

let rec eval calc = 
    match calc with
    | Literal i -> i
    | Mul(a,b) -> eval a * eval b
    | Plus(a,b) -> eval a + eval b
    | Minus(a,b) -> eval a - eval b
let rec print calc =
    match calc with
    | Literal i -> string i
    | Mul(a,b) -> sprintf "(%s * %s)" (print a) (print b)
    | Plus(a,b) -> sprintf "(%s + %s)" (print a) (print b)
    | Minus(a,b) -> sprintf "(%s - %s)" (print a) (print b)
let calc = Mul(Minus(Plus(Literal 42, Literal 2), Literal 1), Literal 3)

printfn "eval %A = %i" (print calc) (eval calc)
giuliohome commented 4 years ago

Btw ... just replacing string i with i.ToString() makes it work

giuliohome commented 4 years ago

I would complain also about the Missing Timezone 🌏 implementation!

open System

let missing = 
    TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time");
Compilation succeeded.
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TimeZoneNotFoundException: Couldn't read time zone file /usr/share/zoneinfo/Central Standard Time ---> System.IO.DirectoryNotFoundException: Could not find a part of the path "/usr/share/zoneinfo/Central Standard Time".
  at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) <0x3922820 + 0x00258> in <b63d6248980146f38423574ef06785b2>:0 
  at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share) <0x395bdb0 + 0x00032> in <b63d6248980146f38423574ef06785b2>:0 
  at System.IO.File.OpenRead (System.String path) <0x395bd70 + 0x0000e> in <b63d6248980146f38423574ef06785b2>:0 
  at System.TimeZoneInfo.FindSystemTimeZoneByFileName (System.String id, System.String filepath) <0x395bbd8 + 0x00014> in <b63d6248980146f38423574ef06785b2>:0 
   --- End of inner exception stack trace ---