-
Notifications
You must be signed in to change notification settings - Fork 830
Open
Labels
Area-Compiler-CodeGenIlxGen, ilwrite and things at the backendIlxGen, ilwrite and things at the backendBugImpact-Low(Internal MS Team use only) Describes an issue with limited impact on existing code.(Internal MS Team use only) Describes an issue with limited impact on existing code.Ready
Milestone
Description
Repro steps
Consider the following code:
type Node =
{
Next: Node
Prev: Node
Value: int
}
let rec one =
{
Next = two
Prev = two
Value = 1
}
and two =
{
Next = one
Prev = one
Value = 2
}
printfn "%A" one
printfn "%A" twoExpected behavior
Either:
- Correctly initialize the mutually recursive values.
- Reject the code as being invalid.
Actual behavior
The code compiles with no warnings/errors. two is initialized correctly, but one.Next and one.Prev are both null:
{ Next = null
Prev = null
Value = 1 }
{ Next = { Next = null
Prev = null
Value = 1 }
Prev = { Next = null
Prev = null
Value = 1 }
Value = 2 }
Known workarounds
None
Related information
Decompiled C# code with incorrect initialization.
Note that a single self-referencing value is actually initialized correctly:
let rec zero =
{
Next = zero
Prev = zero
Value = 0
}Metadata
Metadata
Assignees
Labels
Area-Compiler-CodeGenIlxGen, ilwrite and things at the backendIlxGen, ilwrite and things at the backendBugImpact-Low(Internal MS Team use only) Describes an issue with limited impact on existing code.(Internal MS Team use only) Describes an issue with limited impact on existing code.Ready
Type
Projects
Status
New