Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3214702
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:05:31+00:00 2026-05-17T15:05:31+00:00

open System type Foo() = interface Collections.IEnumerable with member x.GetEnumerator () = null type

  • 0
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

The code above produces the following compilation error:

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.

The code looks perfectly legal and the generic version works fine. Is this an F# compiler bug?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T15:05:31+00:00Added an answer on May 17, 2026 at 3:05 pm

    I think this is a mismatch between the error message an the specification. As kvb points out, the specification allows for ... in in only two cases:

    • When the type implements generic IEnumerable<_> interface (aka seq<_>)
    • When the type has a GetEnumerator method that returns type with certain properties

    If the type implements a non-generic IEnumerable interface then it doesn’t match any of the two conditions. However, if you cast it to IEnumerable then it will actually be the IEnumerable type, which matches the second condition. Having a GetEnumerator member directly in the type (as desco suggests) is also correct, because it also matches the second case.

    So, I think that the error message is incorrect, because it says that implementing non-generic IEnumerable is sufficient, but it is actually not.

    However, there seems to be one actual compiler error related to the for loop. You get a compiler “internal error” when you write the following code (which is not correct, because the inferred generic return type doesn’t implement IEnumerator):

     type Foo() =
       member x.GetEnumerator () = null
     for x in Foo() do ()  // Internal error here
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The code I'm playing with is: open System open System.Windows.Forms open System.Drawing let tehform
I know the dotnetkicks.com system is open source so I can view the code
I've got a Debian Etch system running Exim4-daemon-heavy. The system is open to the
I'm trying to open and read from a serial port using the System.IO.Ports.SerialPort class.
Does anyone know a way to open up an instance of the operating system
What are some tiny open source operating systems? I'm looking for something several orders
Open source implementation will be preferred.
Open up a Rails console and enter this: 2.weeks.ago.between? 2.weeks.ago, 1.week.ago Did it give
I have two Slackware Linux systems on which the POSIX semaphore sem_open() call fails
open_basedir limits the files that can be opened by PHP within a directory-tree. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.