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

Compiler's bug: Field initialization order of record #212

Closed
u1roh opened this issue Feb 4, 2015 · 3 comments
Closed

Compiler's bug: Field initialization order of record #212

u1roh opened this issue Feb 4, 2015 · 3 comments
Labels
Milestone

Comments

@u1roh
Copy link

u1roh commented Feb 4, 2015

Description

Maybe I've found a F# compiler's bug, which is demonstrated in .NET Fiddle. https://dotnetfiddle.net/pLFzQE
I expected that each field initialization of record is evaluated in order, but it isn't.
I checked a spec document of F# 3.0 out, and I found "6.9.11 Evaluating Record Expressions" says
that "Each expression e1 … en is evaluated in order". So, I'm afraid this behavior below is a compiler's bug.

Repro Steps

type Foo = {
  A : int
  B : int
  C : int
}

let _ =
  { A = let _ = printfn "1" in 0
    C = let _ = printfn "2" in 0
    B = let _ = printfn "3" in 0 }

Expected/Actual

I expected the above program prints:
1
2
3

but, actually:
2
1
3

Version

F# 3.0 (FSharp.Core, 4.3.0.0), .NET Framework 4.5

@latkin
Copy link
Contributor

latkin commented Feb 4, 2015

This repros in F# 4.0.

Worth noting that the "A C B" order is the only permutation that results in out-of-order initialization.

forki added a commit to forki/visualfsharp that referenced this issue Feb 4, 2015
forki added a commit to forki/visualfsharp that referenced this issue Feb 4, 2015
forki added a commit to forki/visualfsharp that referenced this issue Feb 4, 2015
forki added a commit to forki/visualfsharp that referenced this issue Feb 4, 2015
forki added a commit to forki/visualfsharp that referenced this issue Feb 4, 2015
forki added a commit to forki/visualfsharp that referenced this issue Feb 4, 2015
@latkin latkin added the Bug label Feb 4, 2015
forki added a commit to forki/visualfsharp that referenced this issue Feb 5, 2015
forki added a commit to forki/visualfsharp that referenced this issue Feb 5, 2015
forki added a commit to forki/visualfsharp that referenced this issue Feb 5, 2015
@dsyme
Copy link
Contributor

dsyme commented May 9, 2015

@forki - any progress (or lessons) for your attempted fix for this or should we try again? thanks

@forki
Copy link
Contributor

forki commented May 9, 2015

I think only the new tests are useful. the fix itself was not correct.

@dsyme dsyme added the pri-2 label May 9, 2015
@dsyme dsyme self-assigned this May 12, 2015
@dsyme dsyme added this to the VS 2015 milestone May 12, 2015
@dsyme dsyme added fix ready and removed pri-2 labels May 12, 2015
@dsyme dsyme closed this as completed in 583503a May 19, 2015
@latkin latkin added the fixed label May 19, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants