You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Mutually recursive computation expression raises NullReferenceException under some conditions #3783
letx()=let reca=seq{yield0yield! b ()}andb()=seq{yield1yield! a }do Seq.take 10 a |> Seq.iter (printfn "%d")
Invoking x () will print a 0 then raises NullReferenceException. Putting the function body into a type constructor generates a similar behavior when creating an instance of it:
typeA()=dolet reca=seq{yield0yield! b ()}andb()=seq{yield1yield! a }do Seq.take 10 a |> Seq.iter (printfn "%d")
One of the workarounds would be inlining the do-binding in the above type definition, like below:
typeA()=let reca=seq{yield0yield! b ()}andb()=seq{yield1yield! a }do Seq.take 10 a |> Seq.iter (printfn "%d")
Another workaround is to modify a so that it becomes a function that takes in a parameter:
I can reproduce this on 15.4.1. Interesting that you can see this on 15.2. @dsyme's PR (#3536) which seems to have caused #3734 was merged long after 15.2 shipped. @dsyme any ideas?
Activity
cartermp commentedon Oct 20, 2017
This looks like a dupe of #3743 - @aqtq314 are you using VS 2017 15.4?
aqtq314 commentedon Oct 20, 2017
I'm on VS Community 2017 15.2 (26430.16), and I cannot reproduce #3743 on my side.
But it does look like the underlying cause is similar.
aqtq314 commentedon Oct 20, 2017
Oh and release mode doesn't help in this one.
aqtq314 commentedon Oct 20, 2017
clicked the wrong button D:
cartermp commentedon Oct 20, 2017
I can reproduce this on 15.4.1. Interesting that you can see this on 15.2. @dsyme's PR (#3536) which seems to have caused #3734 was merged long after 15.2 shipped. @dsyme any ideas?
dsyme commentedon Oct 24, 2017
This is a separate bug. It's odd as we've not had any bugs in closure construction for a long time.
Anyway, it' not a regression but obviously needs to be fixed
2 remaining items
github-actions commentedon Apr 19, 2026
🤖 This is an automated response from Repo Assist.
This issue appears to be fixed on the current
mainbranch. Tested on commit9112d21d43f(F# 11.0, FSI version 15.2.101.0).Reproduction (both variants from the issue):
Both the function-scoped and type-constructor-scoped mutually recursive computation expressions now work correctly without
NullReferenceException.Add regression test for #3783: Mutually recursive computation express…
Add regression test for #3783: Mutually recursive computation express…