Hi,

just a guess but I think the problem might be because the String.Join method got some more overloads in .net 4 - (it can now handle IEnumerable(of String) instead of only arrays and it can handle generic IEnumerable(of T) in conection with T.ToString() of course).

I guess the problem comes from this.

To test this I have written a simple testprogram:

open System

let encode (v) =

v.ToString()

let toQuery nvPairs =

let formattedPairs =

nvPairs

|> Seq.map( fun (n,v) -> n + "=" + encode(v) )

|> Seq.toArray

String.Join("&", formattedPairs)

and yes I get the red lines and the error.

But when I look into the Error List (as hinted by the GUI) I can see that yes there is a confusion by 5 possible overloads - so I don't think you can blame the F# compiler.

Greetings,

Carsten

PS: Hmm it's indeed starge: if I simply say (nvPairs : (string * _) seq) the confusion is gone.

So there seems to be a deeper hidden cause.

Maybe some internal can shed some light here.

By on 7/21/2010 4:40 AM ()

The issue actually has to do with how the + operator is applied to string arguments. Imagine that you created the following types:

1
2
3
4
type A() = 
  static member (+)(a:A,s:string) = B()
type B() =
  static member (+)(b:B,s:string) = obj()

Given this type, then you could give nvPairs the type (A * _) seq, which would result in formattedPairs having the type object[], which would result in calling a different String.Join overload in .NET 4. Thus, you really do need to add an annotation somewhere to help the compiler out.

By on 7/21/2010 2:23 PM ()
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