Skip to content

Commit

Permalink
Cancellable: only cancel on OCE with own token
Browse files Browse the repository at this point in the history
  • Loading branch information
auduchinok committed Jan 28, 2025
1 parent 2edab12 commit ca2d8c9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Compiler/Checking/CheckDeclarations.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5479,7 +5479,7 @@ let rec TcModuleOrNamespaceElementNonMutRec (cenv: cenv) parent typeNames scopem
and [<TailCall>] TcModuleOrNamespaceElementsNonMutRec cenv parent typeNames endm (defsSoFar, env, envAtEnd) (moreDefs: SynModuleDecl list) (ct: CancellationToken) =

if ct.IsCancellationRequested then
ValueOrCancelled.Cancelled (OperationCanceledException())
ValueOrCancelled.Cancelled(OperationCanceledException ct)
else
match moreDefs with
| [] ->
Expand Down
7 changes: 5 additions & 2 deletions src/Compiler/Utilities/Cancellable.fs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,11 @@ module Cancellable =
try
use _ = Cancellable.UsingToken(ct)
oper ct
with :? OperationCanceledException as e ->
ValueOrCancelled.Cancelled(OperationCanceledException e.CancellationToken)
with
| :? OperationCanceledException as e when e.CancellationToken = ct ->
ValueOrCancelled.Cancelled e
| :? OperationCanceledException as e ->
InvalidOperationException("Wrong cancellation token", e) |> raise

let fold f acc seq =
Cancellable(fun ct ->
Expand Down

0 comments on commit ca2d8c9

Please sign in to comment.