From 23937b7fc4d5ab68d0e73e902d4c1879c1074b77 Mon Sep 17 00:00:00 2001 From: Charles Roddie Date: Mon, 14 Sep 2026 08:05:55 +0100 Subject: [PATCH 1/2] Use print/printn for simple string literals and drop redundant sprintf Replace printfn/printf "literal" with printn/print where FSharp.Core 11 is available, remove sprintf around literals with no format specifiers, and fix doc examples missing the $ on interpolated strings. Co-Authored-By: Claude Opus 5 (1M context) --- .../skills/release-notes/pick-insert-line.fsx | 4 +- docs/debug-emit.md | 10 +-- eng/scripts/ExtractTimingsFromBinlog.fsx | 2 +- .../Checking/Expressions/CheckExpressions.fs | 2 +- src/Compiler/Optimize/Optimizer.fs | 2 +- src/Compiler/Service/FSharpCheckerResults.fs | 4 +- src/Compiler/Service/SynExpr.fs | 4 +- src/Compiler/Service/SynPat.fs | 4 +- src/Compiler/TypedTree/TypedTree.fs | 6 +- .../TypedTree/TypedTreeOps.ExprOps.fs | 2 +- src/FSharp.Core/array.fsi | 4 +- src/FSharp.Core/async.fsi | 68 +++++++++---------- src/FSharp.Core/fslib-extra-pervasives.fsi | 2 +- src/FSharp.Core/list.fsi | 2 +- src/FSharp.Core/seq.fsi | 2 +- .../Language/coroutines.fsx | 4 +- .../FSharp.Core/ComparersRegression.fs | 4 +- .../Microsoft.FSharp.Control/AsyncModule.fs | 6 +- .../Microsoft.FSharp.Control/AsyncType.fs | 4 +- ...tinuationsThreadingDetailsStandaloneExe.fs | 4 +- .../Microsoft.FSharp.Control/Tasks.fs | 6 +- .../Microsoft.FSharp.Control/TasksDynamic.fs | 6 +- .../FSharp.Core/OperatorsModule2.fs | 2 +- tests/fsharp/core/attributes/test.fsx | 2 +- tests/fsharp/core/topinit/generate.fsx | 2 +- tests/scripts/codingConventions.fsx | 12 ++-- tests/scripts/identifierAnalysisByType.fsx | 2 +- .../TheBigFileOfDebugStepping.fsx | 16 ++--- .../RemoveUnnecessaryParenthesesTests.fs | 18 ++--- .../tests/UnitTests/TestLib.Utils.fs | 2 +- 30 files changed, 104 insertions(+), 104 deletions(-) diff --git a/.github/skills/release-notes/pick-insert-line.fsx b/.github/skills/release-notes/pick-insert-line.fsx index 40fc8770971..286a86832b9 100644 --- a/.github/skills/release-notes/pick-insert-line.fsx +++ b/.github/skills/release-notes/pick-insert-line.fsx @@ -124,9 +124,9 @@ match lines |> Array.tryFindIndex headerMatches with let anchorIdx, side = candidates.[Random().Next(candidates.Length)] printfn "Insert your new bullet %s this line in %s:" (side.ToUpperInvariant()) rel - printfn "" + printn "" printfn " line %d: %s" (anchorIdx + 1) lines.[anchorIdx] - printfn "" + printn "" if side = "above" then printfn "Use that exact line as the edit anchor: old_str = the line; new_str = \\n." diff --git a/docs/debug-emit.md b/docs/debug-emit.md index 2b0f37391dd..5730545b979 100644 --- a/docs/debug-emit.md +++ b/docs/debug-emit.md @@ -177,10 +177,10 @@ This will have debug points on `for i in 1 .. 10 do` and `yield 1`. The intended debug points for tasks is the same as for the expressions inside the constructs. For example ```fsharp -let f() = task { for i in 1 .. 10 do printfn "hello" } +let f() = task { for i in 1 .. 10 do printn "hello" } ``` -This will have debug points on `for i in 1 .. 10 do` and `printfn "hello"`. +This will have debug points on `for i in 1 .. 10 do` and `printn "hello"`. > NOTE: there are glitches, see further below @@ -201,7 +201,7 @@ Other computation expressions such as `async { .. }` or `builder { ... }` get de * For every `builder.TryFinally` call, a debug point covering the `try` keyword is added immediately within the body lambda expression. A debug point covering the `finally` keyword is added immediately within the finally lambda expression. No debug point is added for the `builder.TryFinally` call itself even if used in statement position. -* For every `builder.Yield`, `builder.Return`, `builder.YieldFrom` or `builder.ReturnFrom` call, debug points are placed on the expression as if it were control flow. For example `yield 1` will place a debug point on `1` and `yield! printfn "hello"; [2]` will place two debug points. +* For every `builder.Yield`, `builder.Return`, `builder.YieldFrom` or `builder.ReturnFrom` call, debug points are placed on the expression as if it were control flow. For example `yield 1` will place a debug point on `1` and `yield! printn "hello"; [2]` will place two debug points. * No debug point is added for the `builder.Run`, `builder.Run` or `builder.Delay` calls at the entrance to the computation expression, nor the `builder.Delay` calls implied by `try/with` or `try/finally` or sequential `Combine` calls. @@ -226,8 +226,8 @@ type C(args) = member _.P = x + f 4 type C(args) = - do printfn "hello" // debug point over `printfn "hello"` as side effect - static do printfn "hello" // debug point over `printfn "hello"` as side effect for static init + do printn "hello" // debug point over `printn "hello"` as side effect + static do printn "hello" // debug point over `printn "hello"` as side effect for static init let f x = x + 1 member _.P = x + f 4 diff --git a/eng/scripts/ExtractTimingsFromBinlog.fsx b/eng/scripts/ExtractTimingsFromBinlog.fsx index b63e55d48eb..ed0c73da069 100644 --- a/eng/scripts/ExtractTimingsFromBinlog.fsx +++ b/eng/scripts/ExtractTimingsFromBinlog.fsx @@ -54,7 +54,7 @@ build.VisitAllChildren(fun task -> printfn "=== %s ===" projectName for msg in timingMessages do printfn " %s" msg - printfn "" + printn "" ) if not foundFscTasks then diff --git a/src/Compiler/Checking/Expressions/CheckExpressions.fs b/src/Compiler/Checking/Expressions/CheckExpressions.fs index fb2ddc9b18d..c9fe1f8b340 100644 --- a/src/Compiler/Checking/Expressions/CheckExpressions.fs +++ b/src/Compiler/Checking/Expressions/CheckExpressions.fs @@ -12768,7 +12768,7 @@ and AnalyzeRecursiveDecl // // Also for // module rec M = - // printfn "hello" // side effects in recursive modules + // printn "hello" // side effects in recursive modules // let x = 1 | SynPat.Const (SynConst.Unit, m) | SynPat.Wild m -> let id = ident (cenv.niceNameGen.FreshCompilerGeneratedName("doval", m), m) diff --git a/src/Compiler/Optimize/Optimizer.fs b/src/Compiler/Optimize/Optimizer.fs index 8ed18f61121..753961aa844 100644 --- a/src/Compiler/Optimize/Optimizer.fs +++ b/src/Compiler/Optimize/Optimizer.fs @@ -1572,7 +1572,7 @@ let AbstractAndRemapModulInfo g (cenv: cenv) (repackage, hidden) info = //------------------------------------------------------------------------- /// Type applications of F# "type functions" may cause side effects, e.g. -/// let x<'a> = printfn "hello"; typeof<'a> +/// let x<'a> = printn "hello"; typeof<'a> /// In this case do not treat them as constants. let IsTyFuncValRefExpr = function | Expr.Val (fv, _, _) -> fv.IsTypeFunction diff --git a/src/Compiler/Service/FSharpCheckerResults.fs b/src/Compiler/Service/FSharpCheckerResults.fs index 6473188a802..01c04ab89cb 100644 --- a/src/Compiler/Service/FSharpCheckerResults.fs +++ b/src/Compiler/Service/FSharpCheckerResults.fs @@ -1180,10 +1180,10 @@ type internal TypeCheckInfo // Do not check a method with same name twice //type AA() = // abstract a: unit -> unit - // default _.a() = printfn "A" + // default _.a() = printn "A" //type BB() = // inherit AA() - // member _.a() = printfn "B" (* This method covered the `AA.a` *) + // member _.a() = printn "B" (* This method covered the `AA.a` *) //type CC() = // inherit BB() // override | (* Here should not suggest to override `AA.a` *) diff --git a/src/Compiler/Service/SynExpr.fs b/src/Compiler/Service/SynExpr.fs index ef320e68a97..c1b5973b749 100644 --- a/src/Compiler/Service/SynExpr.fs +++ b/src/Compiler/Service/SynExpr.fs @@ -819,7 +819,7 @@ module SynExpr = // // let x = (…) // _.member X = (…) - // (printfn "Hello, world.") + // (printn "Hello, world.") | _, SyntaxNode.SynBinding _ :: _ | _, SyntaxNode.SynModule _ :: _ -> false @@ -1110,7 +1110,7 @@ module SynExpr = // { (+x) with … } // { (x + y) with … } // { (x |> f) with … } - // { (printfn "…"; x) with … } + // { (printn "…"; x) with … } | SynExpr.Record(copyInfo = Some(SynExpr.Paren(expr = Is inner), _)), (PrefixApp _ | InfixApp _ | Dangling.Problematic _) | SynExpr.AnonRecd(copyInfo = Some(SynExpr.Paren(expr = Is inner), _)), (PrefixApp _ | InfixApp _ | Dangling.Problematic _) -> true diff --git a/src/Compiler/Service/SynPat.fs b/src/Compiler/Service/SynPat.fs index 1769314d4ed..24d8734a34c 100644 --- a/src/Compiler/Service/SynPat.fs +++ b/src/Compiler/Service/SynPat.fs @@ -130,8 +130,8 @@ module SynPat = // // or // - // let (x) = printfn "…" - // printfn "…" + // let (x) = printn "…" + // printn "…" | _ when // This is arbitrary and will result in some false positives. let maxBacktracking = 10 diff --git a/src/Compiler/TypedTree/TypedTree.fs b/src/Compiler/TypedTree/TypedTree.fs index 052e046242a..5e4b0723d4f 100644 --- a/src/Compiler/TypedTree/TypedTree.fs +++ b/src/Compiler/TypedTree/TypedTree.fs @@ -3589,7 +3589,7 @@ type ValPublicPath = [] member x.DebugText = x.ToString() - override _.ToString() = sprintf "ValPubPath(...)" + override _.ToString() = "ValPubPath(...)" /// Represents an index into the namespace/module structure of an assembly [] @@ -4877,7 +4877,7 @@ type AttribExpr = [] member x.DebugText = x.ToString() - override x.ToString() = sprintf "AttribExpr(...)" + override x.ToString() = "AttribExpr(...)" /// AttribNamedArg(name, type, isField, value) [] @@ -4887,7 +4887,7 @@ type AttribNamedArg = [] member x.DebugText = x.ToString() - override x.ToString() = sprintf "AttribNamedArg(...)" + override x.ToString() = "AttribNamedArg(...)" /// Constants in expressions [] diff --git a/src/Compiler/TypedTree/TypedTreeOps.ExprOps.fs b/src/Compiler/TypedTree/TypedTreeOps.ExprOps.fs index 01259383c7a..6fdd6f81d32 100644 --- a/src/Compiler/TypedTree/TypedTreeOps.ExprOps.fs +++ b/src/Compiler/TypedTree/TypedTreeOps.ExprOps.fs @@ -2257,7 +2257,7 @@ module internal ExprTransforms = | None -> inputExpr | Some(exprR, []) -> exprR | Some(exprR, argsR) -> - //printfn "adjusted...." + //printn "adjusted...." Expr.App(exprR, tyOfExpr g exprR, [], argsR, inputExpr.Range) //--------------------------------------------------------------------------- diff --git a/src/FSharp.Core/array.fsi b/src/FSharp.Core/array.fsi index 397df39d7cb..8a7b9ade7d2 100644 --- a/src/FSharp.Core/array.fsi +++ b/src/FSharp.Core/array.fsi @@ -1506,7 +1506,7 @@ module Array = /// /// let inputs = [| "a"; "b"; "c" |] /// - /// inputs |> Array.iteri (fun i v -> printfn "{i}: {v}") + /// inputs |> Array.iteri (fun i v -> printn $"{i}: {v}") /// /// Evaluates to unit and prints /// @@ -4292,7 +4292,7 @@ module Array = /// /// let inputs = [| "a"; "b"; "c" |] /// - /// inputs |> Array.Parallel.iteri (fun i v -> printfn "{i}: {v}") + /// inputs |> Array.Parallel.iteri (fun i v -> printn $"{i}: {v}") /// /// Evaluates to unit and prints the following to the console in an unspecified order: /// diff --git a/src/FSharp.Core/async.fsi b/src/FSharp.Core/async.fsi index 8f706abf653..5e87c1264cb 100644 --- a/src/FSharp.Core/async.fsi +++ b/src/FSharp.Core/async.fsi @@ -71,16 +71,16 @@ namespace Microsoft.FSharp.Control /// Starting Async Computations /// /// - /// printfn "A" // runs on caller thread + /// printn "A" // runs on caller thread /// /// let result = async { - /// printfn "B" // runs on a background/threadpool thread + /// printn "B" // runs on a background/threadpool thread /// do! Async.Sleep(1000) - /// printfn "C" // continuation runs on a background/threadpool thread + /// printn "C" // continuation runs on a background/threadpool thread /// return 17 /// } |> Async.RunSynchronously /// - /// printfn "D" // runs on caller thread + /// printn "D" // runs on caller thread /// ///

Prints "A", "B" immediately, then "C", "D" after 1 second.

///

Yields result = 17.

@@ -113,16 +113,16 @@ namespace Microsoft.FSharp.Control /// Starting Async Computations /// /// - /// printfn "A" // runs on calling thread + /// printn "A" // runs on calling thread /// /// let result = async { - /// printfn "B" // ALSO runs on calling thread (hence immediately) + /// printn "B" // ALSO runs on calling thread (hence immediately) /// do! Async.Sleep(1000) - /// printfn "C" // runs in continuation context (depends on SynchronizationContext etc) + /// printn "C" // runs in continuation context (depends on SynchronizationContext etc) /// return 17 /// } |> Async.RunSynchronouslyImmediate /// - /// printfn "D" // runs on calling thread + /// printn "D" // runs on calling thread /// ///

Prints "A", "B" immediately, then "C", "D" after 1 second.

///

Yields result = 17.

@@ -141,15 +141,15 @@ namespace Microsoft.FSharp.Control /// /// /// - /// printfn "A" + /// printn "A" /// /// async { - /// printfn "B" + /// printn "B" /// do! Async.Sleep(1000) - /// printfn "C" + /// printn "C" /// } |> Async.Start /// - /// printfn "D" + /// printn "D" /// /// Prints "A", then "D", "B" quickly in any order, and then "C" in 1 second. /// @@ -167,18 +167,18 @@ namespace Microsoft.FSharp.Control /// /// /// - /// printfn "A" + /// printn "A" /// /// let t = /// async { - /// printfn "B" + /// printn "B" /// do! Async.Sleep(1000) - /// printfn "C" + /// printn "C" /// } |> Async.StartAsTask /// - /// printfn "D" + /// printn "D" /// t.Wait() - /// printfn "E" + /// printn "E" /// /// Prints "A", then "D", "B" quickly in any order, then "C", "E" in 1 second. /// @@ -597,7 +597,7 @@ namespace Microsoft.FSharp.Control /// |> Async.RunSynchronously /// |> function /// | Some (i) -> printfn $"{i}" - /// | None -> printfn "No Result" + /// | None -> printn "No Result" ///
/// Prints one randomly selected odd number in 1-2 seconds. If the list is changed to all even numbers, it will /// instead print "No Result". @@ -624,7 +624,7 @@ namespace Microsoft.FSharp.Control /// |> Async.RunSynchronously /// |> function /// | Some (i) -> printfn $"{i}" - /// | None -> printfn "No Result" + /// | None -> printn "No Result" ///
/// Will sometimes print one randomly selected odd number, sometimes throw System.Exception("Even numbers not supported: 2"). /// @@ -1092,12 +1092,12 @@ namespace Microsoft.FSharp.Control /// /// /// async { - /// printfn "A" + /// printn "A" /// do! Async.Sleep(1000) - /// printfn "B" + /// printn "B" /// } |> Async.Start /// - /// printfn "C" + /// printn "C" /// /// Prints "C" and "A" quickly in any order, and then "B" 1 second later /// @@ -1120,11 +1120,11 @@ namespace Microsoft.FSharp.Control /// /// /// async { - /// printfn "A" + /// printn "A" /// do! Async.Sleep(TimeSpan(0, 0, 1)) - /// printfn "B" + /// printn "B" /// } |> Async.Start - /// printfn "C" + /// printn "C" /// /// Prints "C", then "A" quickly, and then "B" 1 second later. /// @@ -1312,15 +1312,15 @@ namespace Microsoft.FSharp.Control /// /// /// - /// printfn "A" + /// printn "A" /// /// async { - /// printfn "B" + /// printn "B" /// do! Async.Sleep(1000) - /// printfn "C" + /// printn "C" /// } |> Async.StartImmediate /// - /// printfn "D" + /// printn "D" /// /// Prints "A", "B", "D" immediately, then "C" in 1 second /// @@ -1347,18 +1347,18 @@ namespace Microsoft.FSharp.Control /// /// /// - /// printfn "A" + /// printn "A" /// /// let t = /// async { - /// printfn "B" + /// printn "B" /// do! Async.Sleep(1000) - /// printfn "C" + /// printn "C" /// } |> Async.StartImmediateAsTask /// - /// printfn "D" + /// printn "D" /// t.Wait() - /// printfn "E" + /// printn "E" /// /// Prints "A", "B", "D" immediately, then "C", "E" in 1 second. /// diff --git a/src/FSharp.Core/fslib-extra-pervasives.fsi b/src/FSharp.Core/fslib-extra-pervasives.fsi index 2dc5ac5418a..964a9f7a0c4 100644 --- a/src/FSharp.Core/fslib-extra-pervasives.fsi +++ b/src/FSharp.Core/fslib-extra-pervasives.fsi @@ -358,7 +358,7 @@ module ExtraTopLevelOperators = /// /// let f (Lazy v) = v + v /// - /// let v = lazy (printf "eval!"; 5+5) + /// let v = lazy (print "eval!"; 5+5) /// /// f v /// f v diff --git a/src/FSharp.Core/list.fsi b/src/FSharp.Core/list.fsi index 82d7c6f5573..646d564e6c8 100644 --- a/src/FSharp.Core/list.fsi +++ b/src/FSharp.Core/list.fsi @@ -1251,7 +1251,7 @@ module List = /// /// let inputs = [ "a"; "b"; "c" ] /// - /// inputs |> List.iteri (fun i v -> printfn "{i}: {v}") + /// inputs |> List.iteri (fun i v -> printn $"{i}: {v}") /// /// Evaluates to unit and prints /// diff --git a/src/FSharp.Core/seq.fsi b/src/FSharp.Core/seq.fsi index 74dcdc89133..9d38c97c790 100644 --- a/src/FSharp.Core/seq.fsi +++ b/src/FSharp.Core/seq.fsi @@ -1449,7 +1449,7 @@ module Seq = /// /// let inputs = ["a"; "b"; "c"] /// - /// inputs |> Seq.iteri (fun i v -> printfn "{i}: {v}") + /// inputs |> Seq.iteri (fun i v -> printn $"{i}: {v}") /// /// /// Evaluates to unit and prints diff --git a/tests/FSharp.Compiler.ComponentTests/Language/coroutines.fsx b/tests/FSharp.Compiler.ComponentTests/Language/coroutines.fsx index 71ffa24f1a6..6497bd89d6e 100644 --- a/tests/FSharp.Compiler.ComponentTests/Language/coroutines.fsx +++ b/tests/FSharp.Compiler.ComponentTests/Language/coroutines.fsx @@ -8,7 +8,7 @@ // coroutine { // printfn "in t1" // yield () -// printfn "hey" +// printn "hey" // } // @@ -222,7 +222,7 @@ let dumpCoroutine (t: Coroutine) = while ( //if verbose then printfn $"[{t.Id}] calling t.MoveNext, will resume at {t.ResumptionPoint}"; t.MoveNext() not t.IsCompleted) do - () // printfn "yield" + () // printn "yield" printfn $"YieldFromFinal called {yieldFromFinalCallCount} times, YieldFrom called {yieldFromCount} times" let expect final standard t = diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/ComparersRegression.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/ComparersRegression.fs index 2d6ce671b0e..bdf7b5166fb 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core/ComparersRegression.fs +++ b/tests/FSharp.Core.UnitTests/FSharp.Core/ComparersRegression.fs @@ -1637,8 +1637,8 @@ module ComparersRegression = make_result_set f items None |> Seq.iteri (fun n result -> if n = 0 - then printf "[|" - else printf ";" + then print "[|" + else print ";" if n % 40 = 0 then printf "\n " printf "%d" result) printfn "\n |]\n" diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Control/AsyncModule.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Control/AsyncModule.fs index fe9ea95ebfb..033bd98ea8e 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Control/AsyncModule.fs +++ b/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Control/AsyncModule.fs @@ -705,8 +705,8 @@ type AsyncModule() = try Async.StartWithContinuations( Async.Sleep(1000), - (fun _ -> printfn "ok"; incr okCount), - (fun _ -> printfn "error"; incr errCount), + (fun _ -> printn "ok"; incr okCount), + (fun _ -> printn "error"; incr errCount), (fun _ -> printfn "cancel"; failwith "BOOM!"), cancellationToken = cts.Token ) @@ -715,7 +715,7 @@ type AsyncModule() = System.Threading.Thread.Sleep 50 try cts.Cancel() with _ -> () System.Threading.Thread.Sleep 1500 - printfn "====" + printn "====" for i = 1 to 3 do test() Assert.AreEqual(0, !okCount) Assert.AreEqual(0, !errCount) diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Control/AsyncType.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Control/AsyncType.fs index d7b19ad4a23..17daa143cec 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Control/AsyncType.fs +++ b/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Control/AsyncType.fs @@ -978,9 +978,9 @@ module AsyncAwaitStackTraceTests = let checkTrace totalCount (e: exn) = let trace = e.StackTrace // stacktrace should be relatively compact and not bloat the logs, so unconditionally print it to save time analyzing regressions - printfn "EDI trace ====" + printn "EDI trace ====" printfn "%s" trace - printfn "==== EDI trace" + printn "==== EDI trace" Assert.NotNull(trace) Assert.Contains("throwAtLevel1", trace) Assert.Contains("level1Task", trace) diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Control/ContinuationsThreadingDetailsStandaloneExe.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Control/ContinuationsThreadingDetailsStandaloneExe.fs index 9fcde7a033a..4f9bfe71453 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Control/ContinuationsThreadingDetailsStandaloneExe.fs +++ b/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Control/ContinuationsThreadingDetailsStandaloneExe.fs @@ -49,7 +49,7 @@ let Main(args) = SWCandContThrowsTimeout(a, 500) let EmptyParallel() = - printf "EmptyParallel " + print "EmptyParallel " let r = SWCandContThrows(Async.Parallel []) printfn "%A" r @@ -168,7 +168,7 @@ let Main(args) = printfn "%A" r let Tests() = - printfn "" + printn "" #if SYNC_CTXT assert(SynchronizationContext.Current <> null) #endif diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Control/Tasks.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Control/Tasks.fs index e0d1a2daddb..cbe61cf4035 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Control/Tasks.fs +++ b/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Control/Tasks.fs @@ -888,7 +888,7 @@ type Basics() = require disposedInner "did not dispose inner after task completion" require (not disposed) "disposed way early" do! Task.Delay(50) - printfn "resumed after delay" + printn "resumed after delay" require (not disposed) "disposed kinda early" } t.Wait() @@ -949,9 +949,9 @@ type Basics() = for x in wrapList do printfn "x = %A, index = %d" x index do! Task.Yield() - printfn "back from yield" + printn "back from yield" do! Task.Yield() - printfn "back from yield" + printn "back from yield" match index with | 0 -> require (x = "a") "wrong first value" | 1 -> require (x = "b") "wrong second value" diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Control/TasksDynamic.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Control/TasksDynamic.fs index 15509a897f5..c50b0d0aa6a 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Control/TasksDynamic.fs +++ b/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Control/TasksDynamic.fs @@ -765,7 +765,7 @@ type Basics() = require disposedInner "did not dispose inner after task completion" require (not disposed) "disposed way early" do! Task.Delay(50) - printfn "resumed after delay" + printn "resumed after delay" require (not disposed) "disposed kinda early" } t.Wait() @@ -826,9 +826,9 @@ type Basics() = for x in wrapList do printfn "x = %A, index = %d" x index do! Task.Yield() - printfn "back from yield" + printn "back from yield" do! Task.Yield() - printfn "back from yield" + printn "back from yield" match index with | 0 -> require (x = "a") "wrong first value" | 1 -> require (x = "b") "wrong second value" diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule2.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule2.fs index 8cbe2087a26..5eca9f0b95a 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule2.fs +++ b/tests/FSharp.Core.UnitTests/FSharp.Core/OperatorsModule2.fs @@ -289,7 +289,7 @@ type OperatorsModule2() = [] member _.lock() = // lock - printfn "test8 started" + printn "test8 started" let syncRoot = System.Object() let mutable k = 0 let comp _ = async { return lock syncRoot (fun () -> k <- k + 1 diff --git a/tests/fsharp/core/attributes/test.fsx b/tests/fsharp/core/attributes/test.fsx index 43a9d8a1ad5..7a84a1205ff 100644 --- a/tests/fsharp/core/attributes/test.fsx +++ b/tests/fsharp/core/attributes/test.fsx @@ -1319,7 +1319,7 @@ module TestFsiLoadOfNonExistentAssembly = try let log4netType = System.Type.GetType("ThisTypeDoes.Not.Exist, thisAssemblyDoesNotExist") let exists = log4netType <> null - if exists then report_failure (sprintf "type existed!") + if exists then report_failure "type existed!" do printfn "%A" exists with e -> report_failure (sprintf "exception unexpected: %s" e.Message) diff --git a/tests/fsharp/core/topinit/generate.fsx b/tests/fsharp/core/topinit/generate.fsx index f81206423c3..5d5e5307e3a 100644 --- a/tests/fsharp/core/topinit/generate.fsx +++ b/tests/fsharp/core/topinit/generate.fsx @@ -119,7 +119,7 @@ let generateTests() = yield "let mutable forceInit = 1"; yield "// This sets a value in another module to indicate that initialization has happened" yield sprintf "InitFlag%d.init <- true" n.Value |]) - yield sprintf "//-----------------" + yield "//-----------------" yield sprintf "printfn \"Touching value in module Lib%d...\"" n.Value yield sprintf "printfn \" --> Lib%d.x = %%A\" Lib%d.x" n.Value n.Value if triggers1 then diff --git a/tests/scripts/codingConventions.fsx b/tests/scripts/codingConventions.fsx index 2c490e31ef1..5c72e60148b 100644 --- a/tests/scripts/codingConventions.fsx +++ b/tests/scripts/codingConventions.fsx @@ -18,14 +18,14 @@ let lines = yield file, (line+1, lineText) |] -printfn "------ LINE LENGTH ANALYSIS ----------" +printn "------ LINE LENGTH ANALYSIS ----------" let totalLines = lines.Length let buckets = lines |> Array.groupBy (fun (_file, (_line, lineText)) -> lineText.Length / 10) |> Array.sortByDescending (fun (key, vs) -> key) for (key, sz) in buckets do printfn "bucket %d-%d - %%%2.1f" (key*10) (key*10+9) (double sz.Length / double totalLines * 100.0) -printfn "top bucket: " +printn "top bucket: " for (file, (line, text)) in snd buckets.[0] do printfn "%s %d %s..." file line text.[0..50] @@ -38,7 +38,7 @@ printfn "%d long lines = %2.2f%%" numLong (double numLong / double totalLines) printfn "%d huge lines = %2.2f%%" numHuge (double numHuge / double totalLines) printfn "%d humongous lines = %2.2f%%" numHumongous (double numHumongous / double totalLines) -printfn "------ SPACE AFTER COMMA ANALYSIS ----------" +printn "------ SPACE AFTER COMMA ANALYSIS ----------" let commas = lines @@ -53,7 +53,7 @@ let commas = printfn "Top files that have commas without spaces: %A" (Array.truncate 10 commas) -printfn "------DANGLING SEMICOLONS----------" +printn "------DANGLING SEMICOLONS----------" let semis = lines @@ -68,7 +68,7 @@ let semis = printfn "Top files that have semicolon at end of line: %A" (Array.truncate 10 semis) -printfn "------NO SPACE AFTER COLON----------" +printn "------NO SPACE AFTER COLON----------" open System.Text.RegularExpressions @@ -85,7 +85,7 @@ let noSpaceAfterColons = printfn "Top files that have no space after colon:\n%A" (Array.truncate 10 noSpaceAfterColons) -printfn "------ SPACE BEFORE COLON----------" +printn "------ SPACE BEFORE COLON----------" let spaceBeforeColon = diff --git a/tests/scripts/identifierAnalysisByType.fsx b/tests/scripts/identifierAnalysisByType.fsx index 8c3ceb2ec7f..8164056e6df 100644 --- a/tests/scripts/identifierAnalysisByType.fsx +++ b/tests/scripts/identifierAnalysisByType.fsx @@ -93,7 +93,7 @@ symbols printfn " %s (%d times)" nm (Array.length entries) for (_, _, vUse) in entries do printfn " %s" vUse - printfn "") + printn "") (* let isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) diff --git a/tests/walkthroughs/DebugStepping/TheBigFileOfDebugStepping.fsx b/tests/walkthroughs/DebugStepping/TheBigFileOfDebugStepping.fsx index b4cb494c81d..1825146cd18 100644 --- a/tests/walkthroughs/DebugStepping/TheBigFileOfDebugStepping.fsx +++ b/tests/walkthroughs/DebugStepping/TheBigFileOfDebugStepping.fsx @@ -174,17 +174,17 @@ let ListExpressionSteppingTest6 () = let ListExpressionSteppingTest7 () = [ for x in 1..4 do - printfn "hello" + printn "hello" yield x ] let ListExpressionSteppingTest8 () = [ for x in 1..4 do match x with | 1 -> - printfn "hello" + printn "hello" yield x | 2 -> - printfn "hello" + printn "hello" yield x | _ -> yield x @@ -1285,13 +1285,13 @@ module ForLoopInGeneratedList = testSimpleListEachArrayLoopWithTwoStatements [|1;2;3|] testSimpleListEachListLoopWithOneStatement [1;2;3] testSimpleListEachListLoopWithInitialLetBindings (fun () -> 7) (fun () -> 8) [1;2;3] - testSimpleListEachListLoopWithInitialSequentialExpression (fun () -> printfn "7") (fun () -> printfn "8") [1;2;3] + testSimpleListEachListLoopWithInitialSequentialExpression (fun () -> printn "7") (fun () -> printn "8") [1;2;3] testSimpleListEachListLoopWithTwoStatements [1;2;3] testSimpleListEachStringLoopWithOneStatement "123" testSimpleListEachStringLoopWithTwoStatements "123" testSimpleListEachIntRangeLoopWithOneStatement (1, 3) testSimpleListEachIntRangeLoopWithInitialLetBindings (fun () -> 7) (fun () -> 8) (1, 3) - testSimpleListEachIntRangeLoopWithInitialSequentialExpression (fun () -> printfn "7") (fun () -> printfn "8") (1, 3) + testSimpleListEachIntRangeLoopWithInitialSequentialExpression (fun () -> printn "7") (fun () -> printn "8") (1, 3) testSimpleListEachIntRangeLoopWithTwoStatements (1, 3) testSimpleListEachIntRangeLoopDownWithOneStatement (1, 3) testSimpleListEachIntRangeLoopDownWithTwoStatements (1, 3) @@ -1406,13 +1406,13 @@ module ForLoopInGeneratedArray = testSimpleArrayEachArrayLoopWithTwoStatements [|1;2;3|] testSimpleArrayEachListLoopWithOneStatement [1;2;3] testSimpleArrayEachListLoopWithInitialLetBindings (fun () -> 7) (fun () -> 8) [|1;2;3|] - testSimpleArrayEachListLoopWithInitialSequentialExpression (fun () -> printfn "7") (fun () -> printfn "8") [|1;2;3|] + testSimpleArrayEachListLoopWithInitialSequentialExpression (fun () -> printn "7") (fun () -> printn "8") [|1;2;3|] testSimpleArrayEachListLoopWithTwoStatements [1;2;3] testSimpleArrayEachStringLoopWithOneStatement "123" testSimpleArrayEachStringLoopWithTwoStatements "123" testSimpleArrayEachIntRangeLoopWithOneStatement (1, 3) testSimpleArrayEachIntRangeLoopWithInitialLetBindings (fun () -> 7) (fun () -> 8) (1, 3) - testSimpleArrayEachIntRangeLoopWithInitialSequentialExpression (fun () -> printfn "7") (fun () -> printfn "8") (1, 3) + testSimpleArrayEachIntRangeLoopWithInitialSequentialExpression (fun () -> printn "7") (fun () -> printn "8") (1, 3) testSimpleArrayEachIntRangeLoopWithTwoStatements (1, 3) testSimpleArrayEachIntRangeLoopDownWithOneStatement (1, 3) testSimpleArrayEachIntRangeLoopDownWithTwoStatements (1, 3) @@ -2081,7 +2081,7 @@ module CancellableBasicTests = let test2() = cancellable { - printfn "hello" + printn "hello" return 12345 } diff --git a/vsintegration/tests/FSharp.Editor.Tests/CodeFixes/RemoveUnnecessaryParenthesesTests.fs b/vsintegration/tests/FSharp.Editor.Tests/CodeFixes/RemoveUnnecessaryParenthesesTests.fs index 7901df88801..786cd1e3255 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/CodeFixes/RemoveUnnecessaryParenthesesTests.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/CodeFixes/RemoveUnnecessaryParenthesesTests.fs @@ -84,8 +84,8 @@ let _ = expectFix code expected [] - let ``Beginning of file: (printfn "Hello, world")`` () = - TopLevel.expectFix "(printfn \"Hello, world\")" "printfn \"Hello, world\"" + let ``Beginning of file: (printn "Hello, world")`` () = + TopLevel.expectFix "(printn \"Hello, world\")" "printn \"Hello, world\"" [] let ``End of file: let x = (1)`` () = @@ -897,21 +897,21 @@ in x "lazy (id 3)", "lazy (id 3)" // Technically we could remove here, but probably better not to. // Sequential - """ (printfn "1"); printfn "2" """, """ printfn "1"; printfn "2" """ - """ printfn "1"; (printfn "2") """, """ printfn "1"; printfn "2" """ + """ (printn "1"); printn "2" """, """ printn "1"; printn "2" """ + """ printn "1"; (printn "2") """, """ printn "1"; printn "2" """ "let x = 3; (5) in x", "let x = 3; 5 in x" """ [ () - (printfn "1"; ()) + (printn "1"; ()) () ] """, """ [ () - (printfn "1"; ()) + (printn "1"; ()) () ] """ @@ -1138,14 +1138,14 @@ in x """ if - (printfn "1" + (printn "1" true) then () """, """ if - (printfn "1" + (printn "1" true) then () @@ -1739,7 +1739,7 @@ in x "id <| (id <| fun x -> x) |> id", "id <| (id <| fun x -> x) |> id" "id <| (id <| id <| id <| fun x -> x) |> id", "id <| (id <| id <| id <| fun x -> x) |> id" "(id <| fun x -> x) |> id", "(id <| fun x -> x) |> id" - """(printfn ""; fun x -> x) |> id""", """(printfn ""; fun x -> x) |> id""" + """(printn ""; fun x -> x) |> id""", """(printn ""; fun x -> x) |> id""" // MatchLambda "id (function x when true -> x | y -> y)", "id (function x when true -> x | y -> y)" diff --git a/vsintegration/tests/UnitTests/TestLib.Utils.fs b/vsintegration/tests/UnitTests/TestLib.Utils.fs index 6032c48b222..de5cac979d8 100644 --- a/vsintegration/tests/UnitTests/TestLib.Utils.fs +++ b/vsintegration/tests/UnitTests/TestLib.Utils.fs @@ -31,7 +31,7 @@ module Asserts = Assert.Fail(message) let ValidateOK (i:int) = if not (i = VSConstants.S_OK) then - let message = sprintf "Expected S_OK" + let message = "Expected S_OK" printfn "%s" message Assert.Fail(message) let Throws<'T when 'T:> Exception> f = From 65e050d94d470213b55910dd7eccaad27ec79f5e Mon Sep 17 00:00:00 2001 From: Charles Roddie Date: Mon, 14 Sep 2026 08:08:34 +0100 Subject: [PATCH 2/2] Use printn in aligned RemoveUnnecessaryParenthesesTests cases Co-Authored-By: Claude Opus 5 (1M context) --- .../RemoveUnnecessaryParenthesesTests.fs | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/vsintegration/tests/FSharp.Editor.Tests/CodeFixes/RemoveUnnecessaryParenthesesTests.fs b/vsintegration/tests/FSharp.Editor.Tests/CodeFixes/RemoveUnnecessaryParenthesesTests.fs index 786cd1e3255..0060264cc78 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/CodeFixes/RemoveUnnecessaryParenthesesTests.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/CodeFixes/RemoveUnnecessaryParenthesesTests.fs @@ -2395,28 +2395,28 @@ let _ = (2 + 2) { return 5 } // See https://github.com/dotnet/fsharp/issues/16999 """ - printfn "1"; printfn ("2"); (id <| match y with Some y -> let y = y - y - | None -> 3) + printn "1"; printn ("2"); (id <| match y with Some y -> let y = y + y + | None -> 3) """, """ - printfn "1"; printfn ("2"); (id <| match y with Some y -> let y = y - y - | None -> 3) + printn "1"; printn ("2"); (id <| match y with Some y -> let y = y + y + | None -> 3) """ // See https://github.com/dotnet/fsharp/issues/16999 """ - printfn ("1" - ); printfn "2"; (id <| match y with Some y -> let y = y - y - | None -> 3) + printn ("1" + ); printn "2"; (id <| match y with Some y -> let y = y + y + | None -> 3) """, """ - printfn ("1" - ); printfn "2"; (id <| match y with Some y -> let y = y - y - | None -> 3) + printn ("1" + ); printn "2"; (id <| match y with Some y -> let y = y + y + | None -> 3) """ }