open System
type Foo() =
interface Collections.IEnumerable with
member x.GetEnumerator() = null
type Bar() =
interface Collections.IEnumerable with
member x.GetEnumerator() = null
interface Collections.Generic.IEnumerable<int> with
member x.GetEnumerator() = null
let xs, ys = Foo(), Bar()
for x in xs do() // <--
for y in ys do() // fine
Le code produit ci-dessus l'erreur de compilation suivante:Est-ce un bug du compilateur F #? # 2
The type 'Foo' is not a type whose values can be enumerated with this syntax, i.e. is not compatible with either seq<_>, IEnumerable<_> or IEnumerable and does not have a GetEnumerator method.
Le code semble parfaitement légal et la version générique fonctionne très bien. Est-ce un bug du compilateur F #?
Merci pour la réponse, Tomas! En fait, j'ai trouvé ce bug et je l'ai envoyé à [email protected] il y a une heure ... – ControlFlow
@ControlFlow: Ah, sûrement, ils vont le réparer plus rapidement s'ils reçoivent deux rapports en une seule heure :-)! –