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 7535617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:20:54+00:00 2026-05-30T06:20:54+00:00

I am new to F#, so I am probably missing something trivial but here

  • 0

I am new to F#, so I am probably missing something trivial but here goes.

This works –

let monthsWith31Days = [| MonthType.January; 
                          MonthType.March;
                          MonthType.May;
                          MonthType.July;
                          MonthType.December |]

But this doesn’t

let monthsWith31Days = [| MonthType.January; 
                          MonthType.March;
                          MonthType.May;
                          MonthType.July;
                          MonthType.August;
                          MonthType.December |]

What I have noted is that it’s not the content itself, but the number of items that matter (even if I change the actual items used). The problem starts when number of items exceed 5.

This is the error I get when I run my NUnit tests –

System.ArgumentException: Value does not fall within expected range.

Any ideas what I’m missing?

Edit:

Entire type definition (two types are related so showing both here) –

type public Month(monthType:MonthType, year:Year) = 
        member public this.Year 
            with get () = year
        member public this.MonthType 
            with get () = monthType

        member public this.GetDaysCount () = 
            let monthsWith31Days = [| MonthType.January; 
                                      MonthType.March;
                                      MonthType.May;
                                      MonthType.July;
                                      MonthType.August;
                                      MonthType.December |]

            let has31 = monthsWith31Days |> Array.filter(fun n -> (int)n = (int)this.monthType) |> Array.length

            if (has31 > 0)
            then 31
//            else if (this.MonthType = MonthType.February)
//            then (if this.Year.Leap then 29 
//                  else 28)
            else 30


    and public Year(ad:int) = 
        member public this.AD
            with get() = ad

        member public this.Months = Enum.GetValues(typeof<MonthType>).Cast().ToArray()
                                    |> Array.map(fun n -> new Month (n, this))

        member public this.GetMonth (index:int) = 
            (this.Months |> Array.filter(fun p-> (int)p.MonthType = index)).First()

        member public this.GetMonth (monthName:string) = 
            let requiredMonthType = Enum.Parse(typeof<MonthType>, monthName) |> unbox<MonthType>
            (this.Months |> Array.filter(fun p-> p.MonthType = requiredMonthType)).First()

        member public this.Leap = 
            if this.AD % 400 = 0 then true
            else if this.AD % 100 = 0 then false
            else if this.AD % 4 = 0 then true
            else false

        member this.DaysCount = if this.Leap then 366 else 365
  • 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-30T06:20:56+00:00Added an answer on May 30, 2026 at 6:20 am

    I actually vaguely recall some bug about creating array literals full of enums on some target CLR platform, where if you had more than 5, then some bad code was generated or something. Maybe you’re hitting that? Are you targeting x64 and CLR2? You can work around the bug by avoiding array literals, and use e.g. a list and then call List.ToArray.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am probably missing something really trivial here, but I cannot get phpunit to
I am fairly new to WPF and am probably missing something simple here. If
I'm using Visual Studio 2008 Pro. I'm probably missing something very obvious here, but
I'm probably missing something very simple but I'm new and it's just easier to
I am probably missing something basic here as this just doesn’t seem to be
I am probably missing something extreamly obvious, but I can't figure this our for
I am probably missing something obvious, but I'm new to Prototype, coming from jQuery.
I am probably missing something here, but I'll try and explain what I want
I'm probably missing something simple here, but I can't find the answer elsewhere. I
I am fairly new to Java so I am probably missing something fundamental here

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.