Skip to content

Commit

Permalink
Merge pull request #238 from fsprojects/cleanup-nowarn-declarations
Browse files Browse the repository at this point in the history
Cleanup or clarify unnecessary `#nowarn` statements
  • Loading branch information
abelbraaksma authored Mar 16, 2024
2 parents 2fc7d94 + cffe832 commit 3d2c998
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
8 changes: 5 additions & 3 deletions src/FSharp.Control.TaskSeq/TaskExtensions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ open System.Threading.Tasks
open Microsoft.FSharp.Core.CompilerServices
open Microsoft.FSharp.Core.LanguagePrimitives.IntrinsicOperators

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

[<AutoOpen>]
module TaskExtensions =
Expand Down Expand Up @@ -42,6 +42,8 @@ module TaskExtensions =

// This will yield with __stack_fin = false
// This will resume with __stack_fin = true

// NOTE (AB): if this extra let-binding isn't here, we get NRE exceptions, infinite loops (end of seq not signaled) and warning FS3513
let __stack_yield_fin = ResumableCode.Yield().Invoke(&sm)
__stack_condition_fin <- __stack_yield_fin

Expand Down
2 changes: 1 addition & 1 deletion src/FSharp.Control.TaskSeq/TaskExtensions.fsi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace FSharp.Control

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

[<AutoOpen>]
module TaskExtensions =
Expand Down
2 changes: 0 additions & 2 deletions src/FSharp.Control.TaskSeq/TaskSeq.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ open System.Collections.Generic
open System.Threading
open System.Threading.Tasks

#nowarn "57"

// Just for convenience
module Internal = TaskSeqInternal

Expand Down
2 changes: 0 additions & 2 deletions src/FSharp.Control.TaskSeq/TaskSeq.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ namespace FSharp.Control
open System.Collections.Generic
open System.Threading.Tasks

#nowarn "1204"

[<AutoOpen>]
module TaskSeqExtensions =
module TaskSeq =
Expand Down
10 changes: 7 additions & 3 deletions src/FSharp.Control.TaskSeq/TaskSeqBuilder.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ namespace FSharp.Control

open System.Diagnostics

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

open System
open System.Collections.Generic
Expand All @@ -12,7 +13,7 @@ open System.Runtime.CompilerServices
open System.Threading.Tasks.Sources

open FSharp.Core.CompilerServices
open FSharp.Core.CompilerServices.StateMachineHelpers
open FSharp.Core.CompilerServices.StateMachineHelpers // raises warning FS0057
open FSharp.Control


Expand Down Expand Up @@ -394,7 +395,7 @@ type TaskSeqBuilder() =

ResumableCode.Combine(task1, task2)

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

Expand All @@ -414,8 +415,11 @@ type TaskSeqBuilder() =

let task = __stack_vtask.AsTask()
let mutable awaiter = task.GetAwaiter()

// This will yield with __stack_fin = false
// This will resume with __stack_fin = true

// NOTE (AB): if this extra let-binding isn't here, we get NRE exceptions, infinite loops (end of seq not signaled) and warning FS3513
let __stack_yield_fin = ResumableCode.Yield().Invoke(&sm)
__stack_condition_fin <- __stack_yield_fin

Expand Down

0 comments on commit 3d2c998

Please sign in to comment.