Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions docs/release-notes/.FSharp.Core/8.0.300.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Fixed

* Preserve original stack traces in resumable state machines generated code if available. ([PR #16568](https://github.com/dotnet/fsharp/pull/16568))
8 changes: 6 additions & 2 deletions src/FSharp.Core/resumable.fs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ module StateMachineHelpers =
"__stateMachine should always be guarded by __useResumableCode and only used in valid state machine implementations"

module ResumableCode =
open System.Runtime.ExceptionServices

let inline GetResumptionFunc (sm: byref<ResumableStateMachine<'Data>>) =
sm.ResumptionDynamicInfo.ResumptionFunc
Expand Down Expand Up @@ -294,7 +295,10 @@ module ResumableCode =
// reraise at the end of the finally block
match savedExn with
| None -> true
| Some exn -> raise exn
| Some exn ->
// This should preserve initial location for the failure (file + line, given they're available).
ExceptionDispatchInfo.Capture(exn).Throw()
true
else
let rf = GetResumptionFunc &sm

Expand Down Expand Up @@ -384,7 +388,7 @@ module ResumableCode =
if __stack_fin then
match savedExn with
| None -> ()
| Some exn -> raise exn
| Some exn -> ExceptionDispatchInfo.Capture(exn).Throw()

__stack_fin
//-- RESUMABLE CODE END
Expand Down