From 9b68944680b4858137c50c65d4c9ce14c89f8349 Mon Sep 17 00:00:00 2001 From: Copilot Date: Tue, 9 Jun 2026 22:10:26 +0200 Subject: [PATCH 1/4] Add failing regression tests for #10819 (fsi.CommandLineArgs ignores --) RED phase: pin down the correct behaviour of fsi.CommandLineArgs when user arguments follow the -- separator. The abbreviated flags -d, -r, -I are currently colon-joined with their next token (e.g. '-- -d 5' becomes '-d:5' instead of staying as two tokens), which these tests assert against. Theory rows fail on current main; the baseline [] passes and locks in the current treatment of non-abbreviated post-'--' args so the GREEN fix cannot regress them. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../fsi/FsiCommandLineArgsTests.fs | 80 +++++++++++++++++++ .../FSharp.Compiler.ComponentTests.fsproj | 1 + 2 files changed, 81 insertions(+) create mode 100644 tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsi/FsiCommandLineArgsTests.fs diff --git a/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsi/FsiCommandLineArgsTests.fs b/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsi/FsiCommandLineArgsTests.fs new file mode 100644 index 00000000000..935cd0e2d58 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsi/FsiCommandLineArgsTests.fs @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +namespace CompilerOptions.Fsi + +open System +open System.IO +open Xunit +open FSharp.Test +open FSharp.Test.Compiler + +/// Regression tests for https://github.com/dotnet/fsharp/issues/10819 +/// fsi.CommandLineArgs must preserve every token after `--` byte-for-byte; +/// in particular abbreviated flags like -d / -r / -I that follow `--` must +/// NOT be colon-joined with their next argument. +module FsiCommandLineArgsTests = + + let private writeProbeScript () : string = + // Prints one ARG= line per element of fsi.CommandLineArgs so the + // test can parse exact contents from stdout. + let body = """ +for a in fsi.CommandLineArgs do + printfn "ARG=%s" a +""" + let path = + Path.Combine( + Path.GetTempPath(), + sprintf "fsi_cmdline_%s.fsx" (Guid.NewGuid().ToString("N"))) + File.WriteAllText(path, body) + path + + let private parseArgsFromStdOut (stdout: string) : string list = + stdout.Split([| '\r'; '\n' |], StringSplitOptions.RemoveEmptyEntries) + |> Array.choose (fun line -> + if line.StartsWith("ARG=") then Some (line.Substring(4)) else None) + |> Array.toList + + /// Run fsi