I can reproduce this problem. Replacing the mutable with a ref yields the correct behavior:

1
2
3
4
5
6
7
    let c = ref 0
    [1; 2; 3]
    |> Seq.iter (fun n -> 
        c := !c + n
        JavaScript.Console.Log("c = " + (!c).ToString());
    )
    JavaScript.Console.Log("last c = " + (!c).ToString());

So something is wrong with the way we deal with mutables through closures. Being able to do that is a new F# 4.0 feature, which is probably why it hasn't been noticed yet.

I submitted this as a ticket, and will look into fixing this soon.

Thanks for the report!

By on 10/14/2015 8:38 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper