Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix non-nested mutrec bindings
  • Loading branch information
dsyme committed Nov 15, 2021
commit d49b30cb9b832555327ec6b63623f9d4b4b1b286
8 changes: 6 additions & 2 deletions src/fsharp/IlxGen.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7552,8 +7552,12 @@ and GenModuleDef cenv (cgbuf: CodeGenBuffer) qname lazyInitInfo eenv x =
GenExnDef cenv cgbuf.mgbuf eenvinner m tc
else
GenTypeDef cenv cgbuf.mgbuf lazyInitInfo eenvinner m tc
for mbind in mbinds do
GenModuleBinding cenv cgbuf qname lazyInitInfo eenvinner m mbind
if mbinds |> List.forall (function ModuleOrNamespaceBinding.Binding _ -> true | _ -> false) then
let recBinds = mbinds |> List.choose (function ModuleOrNamespaceBinding.Binding recBind -> Some recBind | _ -> None)
GenLetRecBindings cenv cgbuf eenv (recBinds, m)
else
for mbind in mbinds do
GenModuleBinding cenv cgbuf qname lazyInitInfo eenvinner m mbind
eenvinner

| TMDefLet(bind, _) ->
Expand Down
27 changes: 27 additions & 0 deletions tests/fsharp/core/letrec/test.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,33 @@ module Test3 =
test "vwekjwve95" (tag()) 2
test "vwekjwve96" (tag()) 3

module Test12384 =
type Node =
{
Next: Node
Value: int
}

let rec one =
{
Next = two
Value = 1
}

and two =
{
Next = one
Value = 2
}
printfn "%A" one
printfn "%A" two
test "cweewlwne1" one.Value 1
test "cweewlwne2" one.Next.Value 2
test "cweewlwne3" one.Next.Next.Value 1
test "cweewlwne4" two.Value 2
test "cweewlwne5" two.Next.Value 1
test "cweewlwne6" two.Next.Next.Value 2

#if TESTS_AS_APP
let RUN() = !failures
#else
Expand Down