Could you post the code? This works for me:

1
2
3
type T() =
  static let x = System.DateTime(1,2,3)
  static member X = x
By on 2/8/2011 8:18 AM ()

Yes, sorry I wasn't entirely clear - the crucial bit is you need to take the address of x. Say by calling a method on it:

1
2
3
4
5
6
7
8
type T() =

  static let x = System.DateTime(1,2,3)

  static member X = 

    x.AddDays (float 2)

If X is a method, same error (I removed that bit from my OP, sorry)

By on 2/8/2011 8:38 AM ()

You're right - this looks like a bug to me. Oddly, it only seems to affect static let-bound instances of value types. I sent a message to fsbugs.

However, the workaround you proposed in your original post does seem to work for me:

1
2
3
4
5
type T() =
  static let x = System.DateTime(1,2,3)
  static member X =
    let x = x
    x.AddDays (float 2) 
By on 2/8/2011 8:54 AM ()

OK, keep me informed of the outcome please.

The actual case I am seeing the exception is more involved, as you might imagine, but I haven't been able to cut it down.

By on 2/9/2011 12:26 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