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

F# compiler bug in release mode in VS2015 Update 1 #759

Closed
ghost opened this issue Dec 3, 2015 · 6 comments
Closed

F# compiler bug in release mode in VS2015 Update 1 #759

ghost opened this issue Dec 3, 2015 · 6 comments
Labels
Impact-High (Internal MS Team use only) Describes an issue with extreme impact on existing code.

Comments

@ghost
Copy link

ghost commented Dec 3, 2015

In F# compound loops where the sequences are defined locally, in release mode only, F# generates a compile-time error saying that the name of the sequence being looped over is not found, generating error FS0971: Undefined value. Bizarrely this seems to be the case only when the outer loop is over the elements of a set.
I am using Visual Studio 2015 Update 1 RTM - 14.0.24720.00

I have managed to repro this in a few simple lines of code. Please see below.

@ghost
Copy link
Author

ghost commented Dec 3, 2015

Code for the repro is below. The upload of zip files does not seem to be working.

module Stuff = 

    /// Does not compile in release build
    let f() =
        let currencies = set [ 1 ; 2 ; 3 ]
        let expiries = [ 3 ; 4 ]
        for ccy in currencies do
            for expiry in expiries do
                printfn "Done"

    /// Does compile in release build
    let f2() =
        let currencies = [ 1 ; 2 ; 3 ]
        let expiries = [ 3 ; 4 ]
        for ccy in currencies do
            for expiry in expiries do
                printfn "Done"
[<EntryPoint>]
let main argv = 
    Stuff.f()
    Stuff.f2()
    0 // return an integer exit code

@mjmckp
Copy link
Contributor

mjmckp commented Dec 3, 2015

Replacing 'set' with 'seq' above also causes the compile error.

@dsyme
Copy link
Contributor

dsyme commented Dec 3, 2015

This is the same as the bug fixed by #756. Let's use this as the tracking issue for the problem.

@KevinRansom KevinRansom added Resolution-Fixed Impact-High (Internal MS Team use only) Describes an issue with extreme impact on existing code. labels Dec 4, 2015
@KevinRansom
Copy link
Member

Fix merged:
commit:
c1e0bc8
PR:
#759

@KevinRansom
Copy link
Member

Thank you for reporting this. The fix is in, it will be in the next release of Visual F#.

@dsyme
Copy link
Contributor

dsyme commented Dec 5, 2015

f you do need to get your code to compile and you are using Update 1, it appears sufficient to place something benign prior to any loop where this problem is occurring, like this:

// do something that doesn't get optimized away
let workaround() = null |> ignore  

let configure () =
 let aSequence = Microsoft.FSharp.Core.Operators.(..) 3 4
 let aString = new string('a',3)
 workaround()
 for _ in aSequence do
   System.Console.WriteLine(aString)

configure ()

That said I really hope a fix is made available as soon as possible.

Obviously these calls should be removed as soon as a fix release is made available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Impact-High (Internal MS Team use only) Describes an issue with extreme impact on existing code.
Projects
None yet
Development

No branches or pull requests

3 participants