Skip to content
Merged
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -321,3 +321,46 @@ module LetUseBangTests =
(Error 748, Line 4, Col 13, Line 4, Col 20,
"This construct may only be used within computation expressions. To return a value from an ordinary function simply write the expression without 'return'.")
]

// https://github.com/dotnet/fsharp/issues/3783
[<Fact>]
let ``Issue 3783 - Mutually recursive computation expression should not raise NullReferenceException`` () =
FSharp """
#nowarn "40"
#nowarn "21"

let x () =
let rec a = seq {
yield 0
yield! b () }
and b () = seq {
yield 1
yield! a }
Seq.take 10 a |> Seq.toList

type A () =
let test =
let rec a = seq {
yield 0
yield! b () }
and b () = seq {
yield 1
yield! a }
Seq.take 10 a |> Seq.toList
member _.Test = test

[<EntryPoint>]
let main _ =
let result1 = x ()
if result1 <> [0; 1; 0; 1; 0; 1; 0; 1; 0; 1] then
failwithf "Function variant failed: %A" result1

let a = A()
if a.Test <> [0; 1; 0; 1; 0; 1; 0; 1; 0; 1] then
failwithf "Type constructor variant failed: %A" a.Test

0
"""
|> asExe
|> compileExeAndRun
|> shouldSucceed