Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Valid code doesn't compile in Release mode #1264

Closed
OkayX6 opened this issue Jun 15, 2016 · 4 comments
Closed

Valid code doesn't compile in Release mode #1264

OkayX6 opened this issue Jun 15, 2016 · 4 comments

Comments

@OkayX6
Copy link
Contributor

OkayX6 commented Jun 15, 2016

I have a perfectly valid code that doesn't compile in Release mode, when defining value let subStr in the code below.

Repro steps

  • Create empty console application
  • Add reference to FSharp.Data 2.3.0
  • Copy-paste the following code into Program.fs:
open FSharp.Data

type StatsResponse = JsonProvider<"""[
  {
    "yesCount": 983,
    "moyCount": 458,
    "noCount": 280,
    "alertCount": 3,
    "idSection": 94,
    "sectionName": "Section A"
  }]""">

type Stats(sectionStats: StatsResponse.Root[]) = 
    let sectionIdToStatsMap =
        sectionStats
        |> Seq.map (fun stats -> stats.IdSection, stats)
        |> dict

    member val SectionStats = sectionIdToStatsMap.Values

let generateReportFromStats (clientStats: #seq<string * Stats>) =
    clientStats
    |> Seq.iter (fun (clientName, stats) ->
        // BUG: it works when swapping the two following lines
        let orderedStats = stats.SectionStats
        let subStr = clientName.Substring(23)

        for s in orderedStats do
            printfn "%s" subStr
    )

[<EntryPoint>]
let main argv = 
    printfn "%A" argv
    0 // return an integer exit code
  • Try to compile...

Expected behavior

Code should compile.

Actual behavior

Code doesn't compile with error: Undefined value 'subStr : string'

Known workarounds

Swap the two lines that start by: let subStr and let orderedStats.

Related information

  • Windows 10 Pro
  • F# 4.0
  • .NET 4.6
  • Visual Studio Enterprise 2015
@smoothdeveloper
Copy link
Contributor

@OkayX6 could you check if #742 is the issue by applying the work around?

@forki
Copy link
Contributor

forki commented Jun 16, 2016

I reproduced with the compiler from VS2015, but somehow I can't reproduce with master.

But I get.

image

@OkayX6
Copy link
Contributor Author

OkayX6 commented Jun 16, 2016

@smoothdeveloper Yes, the workaround is working, so it's unrelated to TypeProviders :).

@dsyme
Copy link
Contributor

dsyme commented Jun 16, 2016

Since this is a duplicate of a bug that has been fixed I will close this

@dsyme dsyme closed this as completed Jun 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants