Skip to content

Commit cffe832

Browse files
committed
Resumable code clarifications and why FS3513 may be raised
1 parent 8286571 commit cffe832

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

src/FSharp.Control.TaskSeq/TaskExtensions.fs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ open Microsoft.FSharp.Core.CompilerServices
88
open Microsoft.FSharp.Core.LanguagePrimitives.IntrinsicOperators
99

1010
// note: these are *not* experimental features anymore, but they forgot to switch off the flag
11-
#nowarn "57" // Experimental library feature, requires '--languversion:preview'.
12-
#nowarn "1204" // This construct is for use by compiled F# code ans should not be used directly.
11+
#nowarn "57" // Experimental library feature, requires '--langversion:preview'.
12+
#nowarn "1204" // This construct is for use by compiled F# code and should not be used directly.
1313

1414
[<AutoOpen>]
1515
module TaskExtensions =
@@ -42,6 +42,8 @@ module TaskExtensions =
4242

4343
// This will yield with __stack_fin = false
4444
// This will resume with __stack_fin = true
45+
46+
// NOTE (AB): if this extra let-binding isn't here, we get NRE exceptions, infinite loops (end of seq not signaled) and warning FS3513
4547
let __stack_yield_fin = ResumableCode.Yield().Invoke(&sm)
4648
__stack_condition_fin <- __stack_yield_fin
4749

src/FSharp.Control.TaskSeq/TaskExtensions.fsi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace FSharp.Control
22

3-
#nowarn "1204" // This construct is for use by compiled F# code ans should not be used directly.
3+
#nowarn "1204" // This construct is for use by compiled F# code and should not be used directly.
44

55
[<AutoOpen>]
66
module TaskExtensions =

src/FSharp.Control.TaskSeq/TaskSeqBuilder.fs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ namespace FSharp.Control
33
open System.Diagnostics
44

55
// note: this is *not* an experimental feature, but they forgot to switch off the flag
6-
#nowarn "57" // Experimental library feature, requires '--languversion:preview'.
6+
#nowarn "57" // Experimental library feature, requires '--langversion:preview'.
77

88
open System
99
open System.Collections.Generic
@@ -395,7 +395,7 @@ type TaskSeqBuilder() =
395395

396396
ResumableCode.Combine(task1, task2)
397397

398-
/// Used by `For`. F# currently doesn't support `while!`, so this cannot be called directly from the CE
398+
/// Used by `For`. Unclear if the new `while!` (from F# 8.0) hits this
399399
member inline _.WhileAsync([<InlineIfLambda>] condition: unit -> ValueTask<bool>, body: ResumableTSC<'T>) : ResumableTSC<'T> =
400400
let mutable condition_res = true
401401

@@ -415,8 +415,11 @@ type TaskSeqBuilder() =
415415

416416
let task = __stack_vtask.AsTask()
417417
let mutable awaiter = task.GetAwaiter()
418+
418419
// This will yield with __stack_fin = false
419420
// This will resume with __stack_fin = true
421+
422+
// NOTE (AB): if this extra let-binding isn't here, we get NRE exceptions, infinite loops (end of seq not signaled) and warning FS3513
420423
let __stack_yield_fin = ResumableCode.Yield().Invoke(&sm)
421424
__stack_condition_fin <- __stack_yield_fin
422425

0 commit comments

Comments
 (0)